JSON_ARRAY_OVERLAP
Learn how to use the JSON_ARRAY_OVERLAP semi-structured data function in PlaidCloud Lakehouse. Checks if there is any overlap between two JSON arrays and...
Checks if there is any overlap between two JSON arrays and returns true if there are common elements; otherwise, it returns false.
SQL Syntax
JSON_ARRAY_OVERLAP(<json_array1>, <json_array2>)
Return Type
The function returns a boolean value:
trueif there is at least one common element between the two JSON arrays,falseif there are no common elements.
SQL Examples
SELECT json_array_overlap(
'["apple", "banana", "cherry"]'::JSON,
'["banana", "kiwi", "mango"]'::JSON
);
-[ RECORD 1 ]-----------------------------------
json_array_overlap('["apple", "banana", "cherry"]'::VARIANT, '["banana", "kiwi", "mango"]'::VARIANT): true
SELECT json_array_overlap(
'["grape", "orange"]'::JSON,
'["apple", "kiwi"]'::JSON
);
-[ RECORD 1 ]-----------------------------------
json_array_overlap('["grape", "orange"]'::VARIANT, '["apple", "kiwi"]'::VARIANT): false