-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add support for UUID and PG_UUID types across Spanner migration utilities. #3905
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,7 +130,7 @@ CREATE TABLE IF NOT EXISTS t_tstzmultirange (id INT8, col VARCHAR, PRIMARY KEY ( | |
| CREATE TABLE IF NOT EXISTS t_tstzrange (id INT8, col VARCHAR, PRIMARY KEY (id)); | ||
| CREATE TABLE IF NOT EXISTS t_tsvector (id INT8, col VARCHAR, PRIMARY KEY (id)); | ||
| CREATE TABLE IF NOT EXISTS t_txid_snapshot (id INT8, col VARCHAR, PRIMARY KEY (id)); | ||
| CREATE TABLE IF NOT EXISTS t_uuid (id INT8, col VARCHAR, PRIMARY KEY (id)); | ||
| CREATE TABLE IF NOT EXISTS t_uuid (id INT8, col uuid, PRIMARY KEY (id)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: all the other types are in capitals. For uniformity, please do the same. |
||
| CREATE TABLE IF NOT EXISTS t_uuid_to_bytes (id INT8, col BYTEA, PRIMARY KEY (id)); | ||
| CREATE TABLE IF NOT EXISTS t_varbit (id INT8, col BYTEA, PRIMARY KEY (id)); | ||
| CREATE TABLE IF NOT EXISTS t_varbit_to_bool_array (id INT8, col BOOL[], PRIMARY KEY (id)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,6 +148,10 @@ static Map<Type, AvroToValueFunction> getGsqlMap() { | |
| avroArrayFieldToSpannerArray( | ||
| recordValue, fieldSchema, AvroToValueMapper::avroFieldToString))); | ||
|
|
||
| gsqlFunctions.put( | ||
| Type.uuid(), | ||
| (recordValue, fieldSchema) -> Value.string(avroFieldToString(recordValue, fieldSchema))); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should add support for UUID array type too
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Array support is out of scope of this PR. |
||
| gsqlFunctions.put( | ||
| Type.json(), | ||
| (recordValue, fieldSchema) -> Value.string(avroFieldToString(recordValue, fieldSchema))); | ||
|
|
@@ -245,6 +249,9 @@ static Map<Type, AvroToValueFunction> getPgMap() { | |
| pgFunctions.put( | ||
| Type.pgDate(), | ||
| (recordValue, fieldSchema) -> Value.date(avroFieldToDate(recordValue, fieldSchema))); | ||
| pgFunctions.put( | ||
| Type.pgUuid(), | ||
| (recordValue, fieldSchema) -> Value.string(avroFieldToString(recordValue, fieldSchema))); | ||
| return pgFunctions; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -561,6 +561,7 @@ public void testAvroValueToArrayBasic() { | |
| assertThat( | ||
| AvroToValueMapper.getGsqlMap().keySet().stream() | ||
| .filter(t -> !t.getCode().equals(Code.ARRAY)) | ||
| .filter(t -> !t.getCode().equals(Code.UUID)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why have we filtered out UUID type here? Shouldn't this test be passing for UUID arrays too? |
||
| .map(t -> t.toString()) | ||
| .sorted() | ||
| .collect(Collectors.toList())) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also check for scenarios where UUID is the PK