-
Notifications
You must be signed in to change notification settings - Fork 600
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(cdc): allow decimal to rw_int256 and varchar #16346
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2177223
feat(cdc): allow decimal to rw_int256 and varchar
KeXiangWang 3567b54
add test
KeXiangWang 99d1d87
small fix
KeXiangWang 7361dc4
fix list
KeXiangWang de02f76
refactor test
KeXiangWang 67e5e09
fix NaN
KeXiangWang bb591df
support inf and -inf
KeXiangWang 9d4577a
support inf and -inf
KeXiangWang ed14b3e
fix test
KeXiangWang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,3 +268,98 @@ SELECT * from person_new order by id; | |
1100 noris [email protected] 1864 2539 enne | ||
1101 white [email protected] 8157 6974 se | ||
1102 spencer [email protected] 9481 6270 angeles | ||
|
||
statement ok | ||
CREATE TABLE numeric_to_rw_int256_shared ( | ||
id int, | ||
num rw_int256, | ||
PRIMARY KEY (id) | ||
) FROM pg_source TABLE 'public.numeric_table'; | ||
|
||
statement ok | ||
CREATE TABLE numeric_to_varchar_shared ( | ||
id int, | ||
num varchar, | ||
PRIMARY KEY (id) | ||
) FROM pg_source TABLE 'public.numeric_table'; | ||
|
||
statement ok | ||
CREATE TABLE numeric_list_to_rw_int256_list_shared ( | ||
id int, | ||
num rw_int256[], | ||
PRIMARY KEY (id) | ||
) FROM pg_source TABLE 'public.numeric_list'; | ||
|
||
statement ok | ||
CREATE TABLE numeric_list_to_varchar_list_shared ( | ||
id int, | ||
num varchar[], | ||
PRIMARY KEY (id) | ||
) FROM pg_source TABLE 'public.numeric_list'; | ||
|
||
|
||
system ok | ||
psql -c " | ||
insert into numeric_table values(102, 57896044618658097711785492504343953926634992332820282019728792003956564819967); | ||
--- 2^255 | ||
insert into numeric_table values(103, 57896044618658097711785492504343953926634992332820282019728792003956564819968); | ||
--- 2^256 | ||
insert into numeric_table values(104, 115792089237316195423570985008687907853269984665640564039457584007913129639936); | ||
insert into numeric_table values(105, 115792089237316195423570985008687907853269984665640564039457584007913129639936.555555); | ||
insert into numeric_table values(106, 'NaN'::numeric); | ||
insert into numeric_table values(107, 'Infinity'::numeric); | ||
" | ||
|
||
sleep 3s | ||
|
||
query II | ||
select * from numeric_to_varchar_shared order by id; | ||
---- | ||
1 3.14 | ||
2 57896044618658097711785492504343953926634992332820282019728792003956564819967 | ||
3 57896044618658097711785492504343953926634992332820282019728792003956564819968 | ||
4 115792089237316195423570985008687907853269984665640564039457584007913129639936 | ||
5 115792089237316195423570985008687907853269984665640564039457584007913129639936.555555 | ||
6 NAN | ||
7 POSITIVE_INFINITY | ||
102 57896044618658097711785492504343953926634992332820282019728792003956564819967 | ||
103 57896044618658097711785492504343953926634992332820282019728792003956564819968 | ||
104 115792089237316195423570985008687907853269984665640564039457584007913129639936 | ||
105 115792089237316195423570985008687907853269984665640564039457584007913129639936.555555 | ||
106 NAN | ||
107 POSITIVE_INFINITY | ||
|
||
# The invalid data for rw_int256 is converted to NULL | ||
query II | ||
select * from numeric_to_rw_int256_shared order by id; | ||
---- | ||
1 NULL | ||
2 57896044618658097711785492504343953926634992332820282019728792003956564819967 | ||
3 NULL | ||
4 NULL | ||
5 NULL | ||
6 NULL | ||
7 NULL | ||
102 57896044618658097711785492504343953926634992332820282019728792003956564819967 | ||
103 NULL | ||
104 NULL | ||
105 NULL | ||
106 NULL | ||
107 NULL | ||
|
||
system ok | ||
psql -c " | ||
DELETE FROM numeric_table WHERE id IN (102, 103, 104, 105, 106, 107); | ||
" | ||
|
||
query II | ||
select * from numeric_list_to_varchar_list_shared order by id; | ||
---- | ||
1 {3.14,6,57896044618658097711785492504343953926634992332820282019728792003956564819967,57896044618658097711785492504343953926634992332820282019728792003956564819968,115792089237316195423570985008687907853269984665640564039457584007913129639936.555555} | ||
2 {NAN,POSITIVE_INFINITY,NEGATIVE_INFINITY} | ||
|
||
query II | ||
select * from numeric_list_to_rw_int256_list_shared order by id; | ||
---- | ||
1 {NULL,6,57896044618658097711785492504343953926634992332820282019728792003956564819967,NULL,NULL} | ||
2 {NULL,NULL,NULL} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Supposed to be
NaN
andInfinity
?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.
Yes. Trying to resolve this issue. If it's too non-trivial, I'll open another PR to fix it. Besides, I also find that in our shared source cdc, the conversion from
pg-numeric
torw-numeric
will also loseInfinity
and-Infinity
. Will fix it soon.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.
🫠Too complicated to fix, as it requires us to know the types in upstream tables when parsing the data in JSON payload. Otherwise, we cannot distinguish whether a string is converted from a numeric or a real varchar.
So in this PR, when mapping pg-numeric to varchar, NaN will be
NAN
, inf will bePOSITIVE_INFINITY
, and -inf will beNEGATIVE_INFINITY
. At least these behavior is aligned among backfiling and normal data updates. Do you think that's acceptable?For the bug in the conversion from pg-numeric to rw-numeric, I'll create a PR later to resolve it.
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.
Create a issue here to record.