Presto array contains an element that likes some pattern Presto array contains an element that likes some pattern sql sql

Presto array contains an element that likes some pattern


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


In newer versions of PrestoSQL (now known as Trino), you can use the any_match function:

WHERE any_match(column, e -> e like '%denied%')


See array operator docs here

contains(array_column,'denied')