Search code examples
sqlprestotrino

Most direct way to check if array contains any non-null values


Currently doing this:

cardinality(filter(my_array, x -> x is not null)) != 0

Is there a more direct way?


Solution

  • Yes, for Trino (since 317 version)/Presto(since 0.230 version) you can use any_match:

    any_match(my_array, x -> x is not null)