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

Support accessing a map with non-literal, non-constant key #14552

Open
findepi opened this issue Feb 7, 2025 · 3 comments
Open

Support accessing a map with non-literal, non-constant key #14552

findepi opened this issue Feb 7, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@findepi
Copy link
Member

findepi commented Feb 7, 2025

Accessing a map with a non-string key doesn't work (at least via DataFusion SQL) and is covered by #11785

Accessing a map with a literal string key works:

query I
SELECT SUM(ints['bytes']) FROM data;
----
5636785

Add support for accessing a map with non-literal key.
For example this should work (and also other cases where key cannot be constant-folded to a literal):

query ok
SELECT SUM(ints['by' || 'tes']) FROM data;

but it does not:

DataFusion error: Error during planning: Failed to coerce arguments to satisfy a call to 'array_element' function: coercion from [Map(Field { name: "entries", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "value", data_type: Int64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, false), Utf8] to the signature ArraySignature(ArrayAndIndexes(1)) failed No function matches the given name and argument types 'array_element(Map(Field { name: "entries", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "value", data_type: Int64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, false), Utf8)'. You might need to add explicit type casts. Candidate functions: array_element(array, index

@findepi findepi added the enhancement New feature or request label Feb 7, 2025
@Lordworms
Copy link
Contributor

take

@alamb
Copy link
Contributor

alamb commented Feb 17, 2025

@findepi findepi changed the title Support accessing a map with non-literal key Support accessing a map with non-literal, non-constant key Feb 19, 2025
@alamb
Copy link
Contributor

alamb commented Feb 20, 2025

@Lordworms improved things here to support "constant resolvable keys" in this PR:

However the general purpose non literal / non constant keys are still not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants