Presto array contains an element that likes some pattern

后端 未结 2 1909
我寻月下人不归
我寻月下人不归 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 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
    

提交回复
热议问题