Skip to content

Commit

Permalink
Case statements for the RANGE type. (GoogleCloudPlatform#415)
Browse files Browse the repository at this point in the history
* Case statements for the RANGE type.

* added test cases for range data type

* see if using different quotes gets the test to pass

* separated tests
  • Loading branch information
vlulla authored May 21, 2024
1 parent 0fc5414 commit c1c515c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions udfs/community/test_cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,24 @@ generate_udf_test("typeof", [
expected_output: `"NUMERIC"`
},
]);
generate_udf_test("typeof", [
{
inputs: [`RANGE<DATE> "[null, 2024-04-25)"`],
expected_output: `"RANGE<DATE>"`
},
]);
generate_udf_test("typeof", [
{
inputs: [`RANGE<DATETIME> "[2021-01-01, 2024-04-25)"`],
expected_output: `"RANGE<DATETIME>"`
},
]);
generate_udf_test("typeof", [
{
inputs: [`RANGE(current_timestamp() - interval 5 day, current_timestamp())`],
expected_output: `"RANGE<TIMESTAMP>"`
},
]);
generate_udf_test("url_decode", [
{
inputs: [
Expand Down
3 changes: 3 additions & 0 deletions udfs/community/typeof.sqlx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ AS ( (
WHEN literal LIKE '[%' THEN 'ARRAY'
WHEN REGEXP_CONTAINS(literal, r'^(STRUCT)?\(') THEN 'STRUCT'
WHEN literal LIKE 'ST_%' THEN 'GEOGRAPHY'
WHEN literal LIKE 'RANGE<DATE>%' THEN 'RANGE<DATE>'
WHEN literal LIKE 'RANGE<DATETIME>%' THEN 'RANGE<DATETIME>'
WHEN literal LIKE 'RANGE<TIMESTAMP>%' THEN 'RANGE<TIMESTAMP>'
WHEN literal = 'NULL' THEN 'NULL'
ELSE
'UNKNOWN'
Expand Down

0 comments on commit c1c515c

Please sign in to comment.