-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Map] Rework MAP
creation method behavior when input is NULL
#11730
Conversation
It seems in the pandas analyzer we already didn't use this NULL_KEY_LIST invalid-reason because it got converted to a STRUCT instead def test_map_nullkeylist(self, pandas, duckdb_cursor):
x = pandas.DataFrame([[{'key': None, 'value': None}]])
# Isn't actually converted to MAP because isinstance(None, list) != True
converted_col = duckdb_cursor.sql("select * from x").df()
duckdb_col = duckdb_cursor.sql("SELECT {key: NULL, value: NULL} as '0'").df()
pandas.testing.assert_frame_equal(duckdb_col, converted_col) Perhaps we want to change this to also created a NULL MAP
This would relax the last requirement to be:
|
What should |
Different PR, I'll push that when this is merged as it depends on this |
Thanks! LGTM |
Merge pull request duckdb/duckdb#11730 from Tishj/map_null_behavior_rework
This PR fixes #11115
Old behavior:
MAP(NULL, [1,2,3])
-> Error: Only LIST types are accepted argumentsMAP([1,2,3], NULL)
-> Error: Only LIST types are accepted argumentsMAP(NULL, NULL)
->{}
(empty map)MAP(NULL::INT[], [1,2,3])
-> Error: Key list can not be NULLMAP([1,2,3], NULL::INT[])
-> Error: Value list can not be NULLMAP(NULL::INT[], NULL::INT[])
-> Error: Key list can not be NULLNew behavior:
MAP(NULL, [1,2,3])
->NULL
MAP([1,2,3], NULL)
->NULL
MAP(NULL, NULL)
->NULL
MAP(NULL::INT[], [1,2,3])
->NULL
MAP([1,2,3], NULL::INT[])
->NULL
MAP(NULL::INT[], NULL::INT[])
->NULL