Skip to content

Commit

Permalink
Merge pull request #256 from duckdb/ubigint
Browse files Browse the repository at this point in the history
Fix  #246 - convert ubigint to `decimal(20,0)` instead of to double to avoid loss of precision
  • Loading branch information
Mytherin authored Sep 4, 2024
2 parents e7e52ec + 2b5f3d6 commit 58dc3d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/postgres_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ LogicalType PostgresUtils::ToPostgresType(const LogicalType &input) {
case LogicalTypeId::UINTEGER:
return LogicalType::BIGINT;
case LogicalTypeId::UBIGINT:
return LogicalType::DECIMAL(20, 0);
case LogicalTypeId::HUGEINT:
return LogicalType::DOUBLE;
default:
Expand Down
27 changes: 27 additions & 0 deletions test/sql/storage/attach_ubigint.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# name: test/sql/storage/attach_ubigint.test
# description: Test inserting/querying UBIGINT
# group: [storage]

require postgres_scanner

require-env POSTGRES_TEST_DATABASE_AVAILABLE

statement ok
PRAGMA enable_verification

statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES)

statement ok
USE s;

statement ok
CREATE OR REPLACE TABLE ubigints(u UBIGINT);

statement ok
INSERT INTO ubigints VALUES (1394265502879208448);

query I
SELECT u::VARCHAR FROM ubigints
----
1394265502879208448

0 comments on commit 58dc3d0

Please sign in to comment.