Presto array contains an element that likes some pattern

后端 未结 2 1915
我寻月下人不归
我寻月下人不归 2021-02-06 10:35

For example, one column in my table is an array, I want to check if that column contains an element that contains substring \"denied\" (so elements like \"denied at 12:00 pm\",

相关标签:
2条回答
  • 2021-02-06 10:57

    See array operator docs here

    contains(array_column,'denied')

    0 讨论(0)
  • 2021-02-06 11:11

    Use presto's array functions:

    • filter(), which returns elements that satisfy the given condition
    • cardinality(), which returns the size of an array:

    Like this:

    where cardinality(filter(myArray, x -> x like '%denied%')) > 0
    
    0 讨论(0)
提交回复
热议问题