How do I check if a map has no keys in Presto? If I have a way to check if an array is empty, I can use the map_keys function to determine if the map is empty.
You can use the cardinality function: https://prestodb.io/docs/current/functions/array.html#cardinality
select cardinality(array[]) = 0;
 _col0
-------
 true
(1 row)
                        To check array is empty just compare it with = array[].
Example:
presto> select (map_keys(map(array[], array[])) = array[]) as is_empty;
 is_empty
----------
 true
(1 row)
Likewise, to check if a map is empty just compare it with = map().
Example:
presto> select (map(array[], array[]) = map()) as is_empty;
 is_empty
----------
 true
(1 row)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With