Last active
September 1, 2016 08:55
-
-
Save yancya/ee0fc79a10b1ae6a79a57bd55dba3939 to your computer and use it in GitHub Desktop.
BigQuery StandardSQL の SQL UDF で書いた、文字列配列の包含判定関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TEMP FUNCTION connotation(a ARRAY<STRING>, b ARRAY<STRING>) | |
RETURNS BOOL AS ((SELECT COUNT(b_) = 0 | |
FROM UNNEST(b) AS b_ | |
LEFT OUTER JOIN UNNEST(a) AS a_ ON b_ = a_ | |
WHERE a_ IS NULL)); | |
SELECT connotation(['a', 'b'], ['a']) --> true | |
, connotation(['a'], ['a', 'b']) --> false | |
, connotation(['a', 'b', 'c'], ['c']) --> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment