Skip to content

chore: add support for UUID in CloudClientExecutor #3671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f8a5603
feat: Add Metrics host for built in metrics (#3519)
surbhigarg92 Dec 5, 2024
6a429b1
feat: introduce java.time variables and methods (#3495)
diegomarquezp Dec 5, 2024
df03ae6
chore(spanner): support multiplexed session for rw transactions in ex…
harshachinta Dec 6, 2024
27c2068
chore: remove unused code and fix some warnings (#3533)
olavloite Dec 8, 2024
b060dfd
feat(spanner): support multiplexed session for Partitioned operations…
pratickchokhani Dec 9, 2024
ebd326b
test: enable more tests on the Emulator (#3535)
olavloite Dec 9, 2024
7e265ac
ci(spanner): Fix nightly job issues (#3522)
sakthivelmanii Dec 10, 2024
7d2534d
chore: add internal option for statement executor type (#3534)
olavloite Dec 10, 2024
725efa3
feat: support 'set local' for retry_aborts_internally (#3532)
olavloite Dec 10, 2024
9172b0d
feat: add opt-in for using multiplexed sessions for blind writes (#3540)
pratickchokhani Dec 11, 2024
5c30ba2
ci(spanner): clean up unused kokoro configurations (#3542)
sakthivelmanii Dec 11, 2024
41e1495
test(spanner): Enabled multiplexed session for partitioned operations…
pratickchokhani Dec 13, 2024
30c2e59
chore(main): release 6.82.1-SNAPSHOT (#3526)
release-please[bot] Dec 13, 2024
1611c0c
deps: update sdk platform java dependencies (#3549)
renovate-bot Dec 13, 2024
f2e3d20
chore: reset default to platform thread (#3551)
olavloite Dec 13, 2024
9640c9a
chore: Update generation configuration at Fri Dec 13 16:21:35 UTC 202…
cloud-java-bot Dec 13, 2024
41673f2
chore(main): release 6.83.0 (#3547)
release-please[bot] Dec 13, 2024
5c77905
chore: make state field volatile in AsyncResultSetImpl (#3550)
olavloite Dec 13, 2024
6354f35
chore: make valid connection properties public (#3546)
olavloite Dec 13, 2024
5cf957d
deps: update opentelemetry.version to v1.45.0 (#3531)
renovate-bot Dec 14, 2024
2758d40
chore(main): release 6.83.1-SNAPSHOT (#3554)
release-please[bot] Dec 14, 2024
e194954
feat(spanner): add jdbc support for external hosts (#3536)
sagnghos Dec 16, 2024
33d22eb
ci(spanner): improve performance of samples tests (#3558)
sakthivelmanii Dec 16, 2024
488aa8c
test: unflake RetryOnInvalidatedSessionTest (#3561)
olavloite Dec 16, 2024
871cb82
ci(spanner): Create a new Sample Slow tests (#3560)
sakthivelmanii Dec 17, 2024
07ee201
chore: Update generation configuration at Sat Dec 14 02:27:24 UTC 202…
cloud-java-bot Dec 18, 2024
dc392e3
test: enable write tests for PostgreSQL (#3529)
olavloite Dec 18, 2024
ee81eba
chore: include session min/max in error message (#3566)
olavloite Dec 18, 2024
8173e51
fix: retry specific internal errors (#3565)
olavloite Dec 18, 2024
0a4d70a
chore: disable native metrics when there are no credentials (#3567)
olavloite Dec 18, 2024
e5185b1
feat: add support for ARRAY<STRUCT> to CloudCilentExecutor (#3544)
larkee Dec 18, 2024
2f580ce
chore: Update generation configuration at Wed Dec 18 05:50:09 UTC 202…
cloud-java-bot Dec 24, 2024
aa70fb7
feat: support for UUID type
gagangupt16 Dec 26, 2024
c243ed7
feat: support for UUID type
Dec 26, 2024
72b697b
Merge branch 'main' of github.com:googleapis/java-spanner into uuid
gagangupt16 Dec 26, 2024
cde6988
Merge branch 'main' of github.com:googleapis/java-spanner into uuid
Dec 26, 2024
49e8f92
fix: unit tests for UUID type
gagangupt16 Dec 27, 2024
73ee379
Merge branch 'main' of github.com:googleapis/java-spanner into uuid
gagangupt16 Dec 27, 2024
1d9a960
Merge branch 'uuid' of github.com:gagangupt16/java-spanner into uuid
gagangupt16 Dec 27, 2024
4d210d7
fix: ignore uuid methods for clirr plugin
gagangupt16 Dec 27, 2024
7bcc098
style: fix indentation
gagangupt16 Dec 31, 2024
4421dff
Merge branch 'main' of github.com:googleapis/java-spanner into uuid
gagangupt16 Dec 31, 2024
517e5e9
Merge branch 'main' into uuid
sakthivelmanii Jan 2, 2025
42f078a
style: fix formatting issue
gagangupt16 Jan 3, 2025
4bc6217
Merge branch 'uuid' of github.com:gagangupt16/java-spanner into uuid
gagangupt16 Jan 3, 2025
971475a
docs: added TODO for removing env checks for integration tests for UUID
gagangupt16 Jan 3, 2025
0f9e774
Merge branch 'main' of github.com:googleapis/java-spanner into uuid
gagangupt16 Jan 3, 2025
d270a08
fix: add missing return statement
gagangupt16 Jan 3, 2025
01ca718
chore: add support for UUID in CloudClientExecutor
gagangupt16 Mar 3, 2025
ff6bab3
chore: add support for UUID in CloudClientExecutor
gagangupt16 Mar 3, 2025
f821e2e
Merge branch 'main' of github.com:googleapis/java-spanner into uuid_e…
gagangupt16 Mar 3, 2025
b4efab8
style: formatting fix
gagangupt16 Mar 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -2897,6 +2898,9 @@ private com.google.spanner.executor.v1.ValueList buildStruct(StructReader struct
case DATE:
value.setDateDaysValue(daysFromDate(struct.getDate(i)));
break;
case UUID:
value.setStringValue(struct.getUuid(i).toString());
break;
case NUMERIC:
String ascii = struct.getBigDecimal(i).toPlainString();
value.setStringValue(ascii);
Expand Down Expand Up @@ -3043,6 +3047,25 @@ private com.google.spanner.executor.v1.ValueList buildStruct(StructReader struct
com.google.spanner.v1.Type.newBuilder().setCode(TypeCode.DATE).build());
}
break;
case UUID:
{
com.google.spanner.executor.v1.ValueList.Builder builder =
com.google.spanner.executor.v1.ValueList.newBuilder();
List<UUID> values = struct.getUuidList(i);
for (UUID uuidValue : values) {
com.google.spanner.executor.v1.Value.Builder valueProto =
com.google.spanner.executor.v1.Value.newBuilder();
if (uuidValue == null) {
builder.addValue(valueProto.setIsNull(true).build());
} else {
builder.addValue(valueProto.setStringValue(uuidValue.toString()).build());
}
}
value.setArrayValue(builder.build());
value.setArrayType(
com.google.spanner.v1.Type.newBuilder().setCode(TypeCode.UUID).build());
}
break;
case TIMESTAMP:
{
com.google.spanner.executor.v1.ValueList.Builder builder =
Expand Down Expand Up @@ -3226,6 +3249,7 @@ private static com.google.cloud.spanner.Key keyProtoToCloudKey(
case BYTES:
case FLOAT64:
case DATE:
case UUID:
case TIMESTAMP:
case NUMERIC:
case JSON:
Expand Down Expand Up @@ -3313,6 +3337,9 @@ private static com.google.cloud.spanner.Value valueProtoToCloudValue(
case DATE:
return com.google.cloud.spanner.Value.date(
value.hasIsNull() ? null : dateFromDays(value.getDateDaysValue()));
case UUID:
return com.google.cloud.spanner.Value.uuid(
value.hasIsNull() ? null : UUID.fromString(value.getStringValue()));
case NUMERIC:
{
if (value.hasIsNull()) {
Expand Down Expand Up @@ -3437,6 +3464,20 @@ private static com.google.cloud.spanner.Value valueProtoToCloudValue(
.collect(Collectors.toList()),
CloudClientExecutor::dateFromDays));
}
case UUID:
if (value.hasIsNull()) {
return com.google.cloud.spanner.Value.uuidArray(null);
} else {
return com.google.cloud.spanner.Value.uuidArray(
unmarshallValueList(
value.getArrayValue().getValueList().stream()
.map(com.google.spanner.executor.v1.Value::getIsNull)
.collect(Collectors.toList()),
value.getArrayValue().getValueList().stream()
.map(com.google.spanner.executor.v1.Value::getStringValue)
.collect(Collectors.toList()),
UUID::fromString));
}
case NUMERIC:
{
if (value.hasIsNull()) {
Expand Down Expand Up @@ -3602,6 +3643,8 @@ private static com.google.cloud.spanner.Type typeProtoToCloudType(
return com.google.cloud.spanner.Type.float64();
case DATE:
return com.google.cloud.spanner.Type.date();
case UUID:
return com.google.cloud.spanner.Type.uuid();
case TIMESTAMP:
return com.google.cloud.spanner.Type.timestamp();
case NUMERIC:
Expand Down Expand Up @@ -3658,6 +3701,8 @@ private static com.google.spanner.v1.Type cloudTypeToTypeProto(@Nonnull Type clo
return com.google.spanner.v1.Type.newBuilder().setCode(TypeCode.TIMESTAMP).build();
case DATE:
return com.google.spanner.v1.Type.newBuilder().setCode(TypeCode.DATE).build();
case UUID:
return com.google.spanner.v1.Type.newBuilder().setCode(TypeCode.UUID).build();
case NUMERIC:
return com.google.spanner.v1.Type.newBuilder().setCode(TypeCode.NUMERIC).build();
case PG_NUMERIC:
Expand Down
42 changes: 42 additions & 0 deletions google-cloud-spanner/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,48 @@
<method>java.util.List getFloat32Array()</method>
</difference>

<!-- UUID -->
<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/spanner/AbstractStructReader</className>
<method>java.util.UUID getUuidInternal(int)</method>
</difference>
<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/spanner/AbstractStructReader</className>
<method>java.util.List getUuidListInternal(int)</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.UUID getUuid(int)</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.UUID getUuid(java.lang.String)</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.List getUuidList(int)</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/StructReader</className>
<method>java.util.List getUuidList(java.lang.String)</method>
</difference>
<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/spanner/Value</className>
<method>java.util.UUID getUuid()</method>
</difference>
<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/spanner/Value</className>
<method>java.util.List getUuidArray()</method>
</difference>

<!-- (Internal change, use stream timeout) -->
<difference>
<differenceType>7012</differenceType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -434,6 +435,11 @@ protected Date getDateInternal(int columnIndex) {
return currRow().getDateInternal(columnIndex);
}

@Override
protected UUID getUuidInternal(int columnIndex) {
return currRow().getUuidInternal(columnIndex);
}

@Override
protected Value getValueInternal(int columnIndex) {
return currRow().getValueInternal(columnIndex);
Expand Down Expand Up @@ -526,6 +532,11 @@ protected List<Date> getDateListInternal(int columnIndex) {
return currRow().getDateListInternal(columnIndex);
}

@Override
protected List<UUID> getUuidListInternal(int columnIndex) {
return currRow().getUuidListInternal(columnIndex);
}

@Override
protected List<Struct> getStructListInternal(int columnIndex) {
return currRow().getStructListInternal(columnIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.function.Function;

/**
Expand Down Expand Up @@ -67,6 +68,8 @@ protected String getPgJsonbInternal(int columnIndex) {

protected abstract Date getDateInternal(int columnIndex);

protected abstract UUID getUuidInternal(int columnIndex);

protected <T extends AbstractMessage> T getProtoMessageInternal(int columnIndex, T message) {
throw new UnsupportedOperationException("Not implemented");
}
Expand Down Expand Up @@ -128,6 +131,8 @@ protected List<String> getPgJsonbListInternal(int columnIndex) {

protected abstract List<Date> getDateListInternal(int columnIndex);

protected abstract List<UUID> getUuidListInternal(int columnIndex);

protected abstract List<Struct> getStructListInternal(int columnIndex);

@Override
Expand Down Expand Up @@ -299,6 +304,19 @@ public Date getDate(String columnName) {
return getDateInternal(columnIndex);
}

@Override
public UUID getUuid(int columnIndex) {
checkNonNullOfType(columnIndex, Type.uuid(), columnIndex);
return getUuidInternal(columnIndex);
}

@Override
public UUID getUuid(String columnName) {
final int columnIndex = getColumnIndex(columnName);
checkNonNullOfType(columnIndex, Type.uuid(), columnName);
return getUuid(columnIndex);
}

@Override
public <T extends ProtocolMessageEnum> T getProtoEnum(
int columnIndex, Function<Integer, ProtocolMessageEnum> method) {
Expand Down Expand Up @@ -583,6 +601,19 @@ public List<Date> getDateList(String columnName) {
return getDateListInternal(columnIndex);
}

@Override
public List<UUID> getUuidList(int columnIndex) {
checkNonNullOfType(columnIndex, Type.array(Type.uuid()), columnIndex);
return getUuidListInternal(columnIndex);
}

@Override
public List<UUID> getUuidList(String columnName) {
final int columnIndex = getColumnIndex(columnName);
checkNonNullOfType(columnIndex, Type.array(Type.uuid()), columnName);
return getUuidList(columnIndex);
}

@Override
public List<Struct> getStructList(int columnIndex) {
checkNonNullArrayOfStruct(columnIndex, columnIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.protobuf.ProtocolMessageEnum;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;
import java.util.function.Function;

/** Forwarding implements of StructReader */
Expand Down Expand Up @@ -225,12 +226,24 @@ public Date getDate(int columnIndex) {
return delegate.get().getDate(columnIndex);
}

@Override
public UUID getUuid(int columnIndex) {
checkValidState();
return delegate.get().getUuid(columnIndex);
}

@Override
public Date getDate(String columnName) {
checkValidState();
return delegate.get().getDate(columnName);
}

@Override
public UUID getUuid(String columnName) {
checkValidState();
return delegate.get().getUuid(columnName);
}

@Override
public boolean[] getBooleanArray(int columnIndex) {
checkValidState();
Expand Down Expand Up @@ -409,6 +422,18 @@ public List<Date> getDateList(String columnName) {
return delegate.get().getDateList(columnName);
}

@Override
public List<UUID> getUuidList(int columnIndex) {
checkValidState();
return delegate.get().getUuidList(columnIndex);
}

@Override
public List<UUID> getUuidList(String columnName) {
checkValidState();
return delegate.get().getUuidList(columnName);
}

@Override
public <T extends AbstractMessage> List<T> getProtoMessageList(int columnIndex, T message) {
checkValidState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -131,6 +132,9 @@ private Object writeReplace() {
case DATE:
builder.set(fieldName).to((Date) value);
break;
case UUID:
builder.set(fieldName).to((UUID) value);
break;
case ARRAY:
final Type elementType = fieldType.getArrayElementType();
switch (elementType.getCode()) {
Expand Down Expand Up @@ -184,6 +188,9 @@ private Object writeReplace() {
case DATE:
builder.set(fieldName).toDateArray((Iterable<Date>) value);
break;
case UUID:
builder.set(fieldName).toUuidArray((Iterable<UUID>) value);
break;
case STRUCT:
builder.set(fieldName).toStructArray(elementType, (Iterable<Struct>) value);
break;
Expand Down Expand Up @@ -298,6 +305,9 @@ private static Object decodeValue(Type fieldType, com.google.protobuf.Value prot
case DATE:
checkType(fieldType, proto, KindCase.STRING_VALUE);
return Date.parseDate(proto.getStringValue());
case UUID:
checkType(fieldType, proto, KindCase.STRING_VALUE);
return UUID.fromString(proto.getStringValue());
case ARRAY:
checkType(fieldType, proto, KindCase.LIST_VALUE);
ListValue listValue = proto.getListValue();
Expand Down Expand Up @@ -347,6 +357,7 @@ static Object decodeArrayValue(Type elementType, ListValue listValue) {
case BYTES:
case TIMESTAMP:
case DATE:
case UUID:
case STRUCT:
case PROTO:
return Lists.transform(listValue.getValuesList(), input -> decodeValue(elementType, input));
Expand Down Expand Up @@ -503,6 +514,12 @@ protected Date getDateInternal(int columnIndex) {
return (Date) rowData.get(columnIndex);
}

@Override
protected UUID getUuidInternal(int columnIndex) {
ensureDecoded(columnIndex);
return (UUID) rowData.get(columnIndex);
}

private boolean isUnrecognizedType(int columnIndex) {
return type.getStructFields().get(columnIndex).getType().getCode() == Code.UNRECOGNIZED;
}
Expand Down Expand Up @@ -624,6 +641,8 @@ protected Value getValueInternal(int columnIndex) {
return Value.timestamp(isNull ? null : getTimestampInternal(columnIndex));
case DATE:
return Value.date(isNull ? null : getDateInternal(columnIndex));
case UUID:
return Value.uuid(isNull ? null : getUuidInternal(columnIndex));
case STRUCT:
return Value.struct(isNull ? null : getStructInternal(columnIndex));
case UNRECOGNIZED:
Expand Down Expand Up @@ -664,6 +683,8 @@ protected Value getValueInternal(int columnIndex) {
return Value.timestampArray(isNull ? null : getTimestampListInternal(columnIndex));
case DATE:
return Value.dateArray(isNull ? null : getDateListInternal(columnIndex));
case UUID:
return Value.uuidArray(isNull ? null : getUuidListInternal(columnIndex));
case STRUCT:
return Value.structArray(
elementType, isNull ? null : getStructListInternal(columnIndex));
Expand Down Expand Up @@ -847,6 +868,12 @@ protected List<Date> getDateListInternal(int columnIndex) {
return Collections.unmodifiableList((List<Date>) rowData.get(columnIndex));
}

@Override
protected List<UUID> getUuidListInternal(int columnIndex) {
ensureDecoded(columnIndex);
return Collections.unmodifiableList((List<UUID>) rowData.get(columnIndex));
}

@Override
@SuppressWarnings("unchecked") // We know ARRAY<STRUCT<...>> produces a List<STRUCT>.
protected List<Struct> getStructListInternal(int columnIndex) {
Expand Down
Loading
Loading