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

Add test that runs DuckDB its test_all_types function #577

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
127 changes: 127 additions & 0 deletions test/regression/expected/test_all_types.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
\x on
SET bytea_output = 'escape';
SELECT * FROM duckdb.query($$
FROM test_all_types()
SELECT * exclude(
tinyint, -- PG14 outputs this differently currently
varint,
TIME,
time_tz,
bit,
small_enum,
medium_enum,
large_enum,
timestamptz_array,
struct,
struct_of_arrays,
array_of_structs,
map,
"union",
fixed_int_array,
fixed_varchar_array,
fixed_nested_int_array,
fixed_nested_varchar_array,
fixed_struct_array,
struct_of_fixed_array,
fixed_array_of_int_list,
list_of_fixed_int_array,
nested_int_array, -- The nested array has different lengths, which is not possible in PG
)
$$)
-[ RECORD 1 ]---+-------------------------------------------------------------------------------------------------------------------------------------
bool | f
smallint | -32768
int | -2147483648
bigint | -9223372036854775808
hugeint | 0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug! We should be returning:

Suggested change
hugeint | 0
hugeint | -170141183460469231731687303715884105728

uhugeint | 0
utinyint | 0
usmallint | 0
uint | 0
ubigint | 0
date | 07-14-5881580
timestamp | Sun Jan 10 08:01:49.551616 294247
timestamp_s | Sun Jan 10 08:01:49.551616 294247
timestamp_ms | Sun Jan 10 08:01:49.551616 294247
timestamp_ns | Wed Sep 22 00:00:00 1677
timestamp_tz | Sun Jan 10 00:01:49.551616 294247 PST
Comment on lines +42 to +47
Copy link
Collaborator Author

@JelteF JelteF Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these underflow currently. I think we should either truncate or throw an error in this case.

float | -3.4028235e+38
double | -1.7976931348623157e+308
dec_4_1 | -999.9
dec_9_4 | -99999.9999
dec_18_6 | -999999999999.999999
dec38_10 | -9999999999999999999999999999.9999999999
uuid | 00000000-0000-0000-0000-000000000000
interval | @ 0
varchar | 🦆🦆🦆🦆🦆🦆
blob | thisisalongblob\000withnullbytes
int_array | {}
double_array | {}
date_array | {}
timestamp_array | {}
varchar_array | {}
-[ RECORD 2 ]---+-------------------------------------------------------------------------------------------------------------------------------------
bool | t
smallint | 32767
int | 2147483647
bigint | 9223372036854775807
hugeint | 170141183460469231731687303715884105727
uhugeint | 340282366920938463463374607431768211455
utinyint | 255
usmallint | 65535
uint | 4294967295
ubigint | 18446744073709551615
date | 07-10-5881580
timestamp | Sun Jan 10 04:00:54.775806 294247
timestamp_s | Sun Jan 10 04:00:54 294247
timestamp_ms | Sun Jan 10 04:00:54.775 294247
timestamp_ns | Fri Apr 11 23:47:16.854775 2262
timestamp_tz | Sat Jan 09 20:00:54.775806 294247 PST
float | 3.4028235e+38
double | 1.7976931348623157e+308
dec_4_1 | 999.9
dec_9_4 | 99999.9999
dec_18_6 | 999999999999.999999
dec38_10 | 9999999999999999999999999999.9999999999
uuid | ffffffff-ffff-ffff-ffff-ffffffffffff
interval | @ 83 years 3 mons 999 days 16 mins 39.999999 secs
varchar | goo
blob | \000\000\000a
int_array | {42,999,NULL,NULL,-42}
double_array | {42,NaN,Infinity,-Infinity,NULL,-42}
date_array | {01-01-1970,07-11-5881580,07-13-5881580,NULL,05-12-2022}
Copy link
Collaborator Author

@JelteF JelteF Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the two dates in the middle are displayed by duckdb as infinity and -infinity, same for the timestamp_array below. Would be worth looking into what is up with those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out infinity and -infinity are valid values for dates/timestamps in both Postgres and DuckDB. But based on this our conversion of these is lacking.

timestamp_array | {"Thu Jan 01 00:00:00 1970","Sun Jan 10 04:00:54.775807 294247","Sun Jan 10 04:00:54.775809 294247",NULL,"Thu May 12 16:23:45 2022"}
varchar_array | {🦆🦆🦆🦆🦆🦆,goose,NULL,""}
-[ RECORD 3 ]---+-------------------------------------------------------------------------------------------------------------------------------------
bool |
smallint |
int |
bigint |
hugeint |
uhugeint |
utinyint |
usmallint |
uint |
ubigint |
date |
timestamp |
timestamp_s |
timestamp_ms |
timestamp_ns |
timestamp_tz |
float |
double |
dec_4_1 |
dec_9_4 |
dec_18_6 |
dec38_10 |
uuid |
interval |
varchar |
blob |
int_array |
double_array |
date_array |
timestamp_array |
varchar_array |

1 change: 1 addition & 0 deletions test/regression/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test: execution_error
test: extensions
test: type_support
test: array_type_support
test: test_all_types
test: views
test: non_superuser
test: projection_pushdown_unsupported_type
Expand Down
30 changes: 30 additions & 0 deletions test/regression/sql/test_all_types.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
\x on
SET bytea_output = 'escape';
SELECT * FROM duckdb.query($$
FROM test_all_types()
SELECT * exclude(
tinyint, -- PG14 outputs this differently currently
varint,
TIME,
time_tz,
bit,
small_enum,
medium_enum,
large_enum,
timestamptz_array,
struct,
struct_of_arrays,
array_of_structs,
map,
"union",
fixed_int_array,
fixed_varchar_array,
fixed_nested_int_array,
fixed_nested_varchar_array,
fixed_struct_array,
struct_of_fixed_array,
fixed_array_of_int_list,
list_of_fixed_int_array,
nested_int_array, -- The nested array has different lengths, which is not possible in PG
)
$$)