-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support BigQuery Structs, DuckDB structs and translation
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
- Loading branch information
1 parent
40e39f4
commit 12aed9a
Showing
8 changed files
with
374 additions
and
13 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
-- provided | ||
SELECT ASCII('abcd') as A, ASCII('a') as B, ASCII('') as C, ASCII(NULL) as D; | ||
SELECT | ||
DATE_DIFF('2017-12-30', '2014-12-30', YEAR) AS year_diff, | ||
DATE_DIFF('2017-12-30', '2014-12-30', ISOYEAR) AS isoyear_diff; | ||
|
||
-- expected | ||
SELECT | ||
DATE_DIFF('YEAR', DATE '2014-12-30', DATE '2017-12-30' ) AS year_diff, | ||
DATE_DIFF('ISOYEAR', DATE '2014-12-30', DATE '2017-12-30') AS isoyear_diff; | ||
|
||
-- result | ||
"A","B","C","D" | ||
"97","97","0","" | ||
"year_diff","isoyear_diff" | ||
"3","2" | ||
|
44 changes: 44 additions & 0 deletions
44
src/test/resources/com/manticore/transpiler/google_bigquery/structure.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- provided | ||
SELECT t, len, LPAD(t, len) AS padded FROM UNNEST([ | ||
STRUCT<t VARCHAR, len integer>('abc', 5 ), | ||
('abc', 2), | ||
('例子', 4) | ||
]); | ||
|
||
-- expected | ||
SELECT t, len, CASE TYPEOF(T) WHEN 'VARCHAR' THEN LPAD(T::VARCHAR, LEN,' ') END AS padded from ( | ||
select Unnest([ | ||
{t:'abc', len:5 }::STRUCT(t VARCHAR, len integer), | ||
('abc', 2), | ||
('例子', 4) | ||
], recursive => true) | ||
); | ||
|
||
-- result | ||
"t","len","padded" | ||
"abc","5"," abc" | ||
"abc","2","ab" | ||
"例子","4"," 例子" | ||
|
||
|
||
-- provided | ||
SELECT t, len, LPAD(t, len) AS padded FROM UNNEST([ | ||
STRUCT('abc' AS t, 5 AS len), | ||
('abc', 2), | ||
('例子', 4) | ||
]); | ||
|
||
-- expected | ||
SELECT t, len, CASE TYPEOF(T) WHEN 'VARCHAR' THEN LPAD(T::VARCHAR, LEN,' ') END AS padded from ( | ||
select Unnest([ | ||
{t:'abc', len:5 }, | ||
('abc', 2), | ||
('例子', 4) | ||
], recursive => true) | ||
); | ||
|
||
-- result | ||
"t","len","padded" | ||
"abc","5"," abc" | ||
"abc","2","ab" | ||
"例子","4"," 例子" |
Oops, something went wrong.