0

So I am trying to apply a simple like function for a Qubole query on Presto. For a string datatype I can simply do like '%United States of America%'.

However for the column I am trying to apply this has the underlying datatype as "map" and thus the query is failing. How do I write the like operator for the map datatype so that it fetches only those columns that match the pattern.

1 Answer 1

1

Please refer to the documentation about map related functions in Presto at https://trino.io/docs/current/functions/map.html

You should be able to make use of map_filter to filter out the required entries. E.g.:

SELECT map_filter(MAP(ARRAY['India', 'Poland', 'United States of America'], ARRAY[20, 3, 15]), (k, v) -> k like '%United States of America%');

             _col0             
-------------------------------
 {United States of America=15} 
(1 row)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.