Skip to content

Commit

Permalink
support inf and -inf
Browse files Browse the repository at this point in the history
  • Loading branch information
KeXiangWang committed Apr 19, 2024
1 parent bb591df commit 9d4577a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions e2e_test/source/cdc/cdc.share_stream.slt
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ select * from numeric_to_varchar_shared order by id;
3 57896044618658097711785492504343953926634992332820282019728792003956564819968
4 115792089237316195423570985008687907853269984665640564039457584007913129639936
5 115792089237316195423570985008687907853269984665640564039457584007913129639936.555555
6 NaN
7 NULL
6 NAN
7 POSITIVE_INFINITY
102 57896044618658097711785492504343953926634992332820282019728792003956564819967
103 57896044618658097711785492504343953926634992332820282019728792003956564819968
104 115792089237316195423570985008687907853269984665640564039457584007913129639936
Expand Down
8 changes: 5 additions & 3 deletions src/connector/src/parser/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,13 @@ fn pg_numeric_to_varchar(val: Option<PgNumeric>) -> Option<ScalarImpl> {

fn pg_numeric_to_string(val: Option<PgNumeric>) -> Option<String> {
if let Some(pg_numeric) = val {
// TODO(kexiang): NEGATIVE_INFINITY -> -Infinity, POSITIVE_INFINITY -> Infinity, NAN -> NaN
// The current implementation is to ensure consistency with the behavior of cdc event parsor.
match pg_numeric {
PgNumeric::NegativeInf => Some(String::from("-Infinity")),
PgNumeric::NegativeInf => Some(String::from("NEGATIVE_INFINITY")),
PgNumeric::Normalized(big_decimal) => Some(big_decimal.to_string()),
PgNumeric::PositiveInf => Some(String::from("Infinity")),
PgNumeric::NaN => Some(String::from("NaN")),
PgNumeric::PositiveInf => Some(String::from("POSITIVE_INFINITY")),
PgNumeric::NaN => Some(String::from("NAN")),
}
} else {
// NULL
Expand Down

0 comments on commit 9d4577a

Please sign in to comment.