简体   繁体   中英

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?

示例数组列:

Expected output after wildcard search:

在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM