-
Notifications
You must be signed in to change notification settings - Fork 1.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
Access a Map
with Primitive type keys
#12259
base: main
Are you sure you want to change the base?
Changes from 11 commits
72119dd
ebf663e
95b1868
afd7f11
4f850c6
c32fedb
0b342a4
a05143a
494c384
1b19eb9
41b2b59
568223e
28a7dff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -482,23 +482,28 @@ SELECT MAP { 'a': 1, 2: 3 }; | |
---- | ||
{a: 1, 2: 3} | ||
|
||
# TODO(https://github.com/apache/datafusion/issues/11785): fix accessing map with non-string key | ||
# query ? | ||
# SELECT MAP { 1: 'a', 2: 'b', 3: 'c' }[1]; | ||
# ---- | ||
# a | ||
|
||
query T | ||
SELECT MAP { 1: 'a', 2: 'b', 3: 'c' }[1]; | ||
---- | ||
a | ||
|
||
# TODO(https://github.com/apache/datafusion/issues/11785): fix accessing map with non-string key | ||
# query ? | ||
# SELECT MAP { MAP {1:'a', 2:'b'}:1, MAP {1:'c', 2:'d'}:2 }[MAP {1:'a', 2:'b'}]; | ||
# ---- | ||
# 1 | ||
|
||
# TODO(https://github.com/apache/datafusion/issues/11785): fix accessing map with non-string key | ||
# query ? | ||
# SELECT MAKE_MAP(1, null, 2, 33, 3, null)[2]; | ||
# ---- | ||
# 33 | ||
query I | ||
SELECT MAKE_MAP(1, null, 2, 33, 3, null)[2]; | ||
---- | ||
33 | ||
|
||
query T | ||
SELECT MAP { 1.0: 'a', 2.0: 'b', 3.0: 'c' }[2.0]; | ||
---- | ||
b | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current implmentation will throw an error. Just checked DuckDB, it try to cast the index to keys data type. |
||
|
||
## cardinality | ||
|
||
|
@@ -572,4 +577,4 @@ statement ok | |
drop table map_array_table_1; | ||
|
||
statement ok | ||
drop table map_array_table_2; | ||
drop table map_array_table_2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use
map_extract
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map_extract
returns a list containing the value. Maybe can wrap it aroundget_field
call and extract the value. But i am not sure, let me try it out.