Closed mdwaud closed 6 months ago
Hmmm... array_length
is telling me it's there, though:
In postgres
postgres=# SELECT ARRAY_LENGTH(ARRAY[1, NULL], 1);
array_length
--------------
2
(1 row)
In datafusion-postgres
datafusion=> SELECT ARRAY_LENGTH(ARRAY[1, NULL], 1);
array_length(make_array(Int64(1),NULL),Int64(1))
--------------------------------------------------
2
(1 row)
Let me see if I can come up with a better example to reproduce what I'm seeing. For context, I have a column in data fusion where a value may be None
. In psql I am seeing an empty list when the value is None
(instead of [None]
). It's possible there's an error in my setup.
Yeah, I think it's just how pgwire serialize NULL
value. It should be text NULL
instead of empty string.
Just learned that postgres only uses NULL for NULL value in array (and other compound data strcutures maybe)
🎉 I can confirm that https://github.com/sunng87/pgwire/pull/174 fixed the issue. The reason I found this is that I'm using sqlx in a test suite on the output of a query.
One other thing I noticed is that booleans appear to have a similar issue. Ex:
In postgres
postgres=# SELECT false;
bool
------
f
(1 row)
In datafusion-postgres (pgwire)
datafusion=> SELECT false;
Boolean(false)
----------------
false
(1 row)
My test is failing because sqlx only accepts t
/ f
(https://github.com/launchbadge/sqlx/blob/main/sqlx-postgres/src/types/bool.rs), however it's unclear what the official postgres spec is on this.
Thank you for pointing out. I added another fix for to_sql_text
for bool
.
I just released a new version of pgwire to include this fix. You can also test latest HEAD from this repo
Thanks for the quick response!
I have a list where some elements may be
NULL
. Unfortunately they aren't showing up in the return, for example:In postgres
In datafusion