Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Wildcard search for array<string> in Athena

I have a table in Athena where one of the columns is of type array.
I tried the below query to get output containing earth but doesn’t work.
How do I perform a wildcard search in this column?

Example array column:

Expected output after wildcard search:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

select * from mytable
where contains(myarr,'eart%');

>Solution :

This is from memory, so it might need a bit of tweaking, but you can use a filter on the array elements

where cardinality(filter(myarr, q -> q like 'eart%')) > 0

filter creates an array of matches and cardinality tests for one or more elements in the array

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading