Skip to content
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

feat: support for UUID type #3572

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
51 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
ec8a0b2
Merge branch 'main' into uuid
gagangupt16 Jan 8, 2025
b9925d1
Merge branch 'main' into uuid
gagangupt16 Jan 9, 2025
430e7c7
Merge branch 'main' into uuid
gagangupt16 Jan 13, 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
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>
gagangupt16 marked this conversation as resolved.
Show resolved Hide resolved
<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 @@ -430,6 +431,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 @@ -522,6 +528,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);
gagangupt16 marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.spanner.v1.ResultSetStats;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;
import java.util.function.Function;

/** Utility methods for working with {@link com.google.cloud.spanner.ResultSet}. */
Expand Down Expand Up @@ -321,11 +322,21 @@ public Date getDate(int columnIndex) {
return getCurrentRowAsStruct().getDate(columnIndex);
}

@Override
public UUID getUuid(int columnIndex) {
return getCurrentRowAsStruct().getUuid(columnIndex);
}

@Override
public Date getDate(String columnName) {
return getCurrentRowAsStruct().getDate(columnName);
}

@Override
public UUID getUuid(String columnName) {
return getCurrentRowAsStruct().getUuid(columnName);
}

@Override
public <T extends AbstractMessage> T getProtoMessage(int columnIndex, T message) {
return getCurrentRowAsStruct().getProtoMessage(columnIndex, message);
Expand Down Expand Up @@ -508,6 +519,16 @@ public List<Date> getDateList(String columnName) {
return getCurrentRowAsStruct().getDateList(columnName);
}

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

@Override
public List<UUID> getUuidList(String columnNameÏ) {
return getCurrentRowAsStruct().getUuidList(columnNameÏ);
}

@Override
public <T extends AbstractMessage> List<T> getProtoMessageList(int columnIndex, T message) {
return getCurrentRowAsStruct().getProtoMessageList(columnIndex, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Function;
import javax.annotation.concurrent.Immutable;

Expand Down Expand Up @@ -226,6 +227,11 @@ protected Date getDateInternal(int columnIndex) {
return values.get(columnIndex).getDate();
}

@Override
protected UUID getUuidInternal(int columnIndex) {
return values.get(columnIndex).getUuid();
}

@Override
protected <T extends AbstractMessage> T getProtoMessageInternal(int columnIndex, T message) {
return values.get(columnIndex).getProtoMessage(message);
Expand Down Expand Up @@ -334,6 +340,11 @@ protected List<Date> getDateListInternal(int columnIndex) {
return values.get(columnIndex).getDateArray();
}

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

@Override
protected List<Struct> getStructListInternal(int columnIndex) {
return values.get(columnIndex).getStructArray();
Expand Down Expand Up @@ -420,6 +431,8 @@ private Object getAsObject(int columnIndex) {
return getTimestampInternal(columnIndex);
case DATE:
return getDateInternal(columnIndex);
case UUID:
return getUuidInternal(columnIndex);
case STRUCT:
return getStructInternal(columnIndex);
case ARRAY:
Expand Down Expand Up @@ -451,6 +464,8 @@ private Object getAsObject(int columnIndex) {
return getTimestampListInternal(columnIndex);
case DATE:
return getDateListInternal(columnIndex);
case UUID:
return getUuidListInternal(columnIndex);
case STRUCT:
return getStructListInternal(columnIndex);
default:
Expand Down
Loading