You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "theelderbeever (via GitHub)" <gi...@apache.org> on 2025/09/23 04:03:49 UTC

Re: [D] How to access Map array by field [datafusion]

GitHub user theelderbeever closed a discussion: How to access Map array by field

I have a MapArray column that I am reading from a parquet table. I am trying to access particular key/value pairs in that map. 

I was attempting this SQL expression `SELECT tags['account'] FROM metrics` however, I get the error

> Error: Generic("Error during planning: The expression to get an indexed field is only valid for `List` or `Struct` types, got Map(Field { name: \"entries\", data_type: Struct([Field { name: \"keys\", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: \"values\", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, false)")

The parquet file was generated using a MapBuilder from arrow so the type should be correct. How can I query the keys in a Map array?

GitHub link: https://github.com/apache/datafusion/discussions/7851

----
This is an automatically sent email for github@datafusion.apache.org.
To unsubscribe, please send an email to: github-unsubscribe@datafusion.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org