JSON_ARRAY_INTERSECTION (Lakehouse v1)
Zwraca elementy wspólne dla dwóch tablic JSON.
Składnia SQL
Dział zatytułowany „Składnia SQL”JSON_ARRAY_INTERSECTION(<json_array1>, <json_array2>)Typ zwracany
Dział zatytułowany „Typ zwracany”Tablica JSON.
Przykłady SQL
Dział zatytułowany „Przykłady SQL”-- Find the intersection of two JSON arraysSELECT json_array_intersection('["Electronics", "Books", "Toys"]'::JSON, '["Books", "Fashion", "Electronics"]'::JSON);
-[ RECORD 1 ]-----------------------------------json_array_intersection('["Electronics", "Books", "Toys"]'::VARIANT, '["Books", "Fashion", "Electronics"]'::VARIANT): ["Electronics","Books"]
-- Find the intersection of the result from the first query with a third JSON array using an iterative approachSELECT json_array_intersection( json_array_intersection('["Electronics", "Books", "Toys"]'::JSON, '["Books", "Fashion", "Electronics"]'::JSON), '["Electronics", "Books", "Clothing"]'::JSON);
-[ RECORD 1 ]-----------------------------------json_array_intersection(json_array_intersection('["Electronics", "Books", "Toys"]'::VARIANT, '["Books", "Fashion", "Electronics"]'::VARIANT), '["Electronics", "Books", "Clothing"]'::VARIANT): ["Electronics","Books"]