-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bigquery): use sqlglot to implement functional unnest to relatio…
…nal unnest
- Loading branch information
Showing
13 changed files
with
156 additions
and
71 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
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
15 changes: 15 additions & 0 deletions
15
ibis/backends/bigquery/tests/unit/snapshots/test_compiler/test_unnest/out_one_unnest.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,15 @@ | ||
SELECT | ||
t0.`rowindex`, | ||
IF(pos = pos_2, repeated_struct_col, NULL) AS repeated_struct_col | ||
FROM array_test AS t0, UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(t0.`repeated_struct_col`)) - 1)) AS pos | ||
CROSS JOIN UNNEST(t0.`repeated_struct_col`) AS repeated_struct_col WITH OFFSET AS pos_2 | ||
WHERE | ||
pos = pos_2 | ||
OR ( | ||
pos > ( | ||
ARRAY_LENGTH(t0.`repeated_struct_col`) - 1 | ||
) | ||
AND pos_2 = ( | ||
ARRAY_LENGTH(t0.`repeated_struct_col`) - 1 | ||
) | ||
) |
30 changes: 30 additions & 0 deletions
30
ibis/backends/bigquery/tests/unit/snapshots/test_compiler/test_unnest/out_two_unnests.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,30 @@ | ||
SELECT | ||
IF(pos = pos_2, level_two, NULL) AS level_two | ||
FROM ( | ||
SELECT | ||
t1.`rowindex`, | ||
IF(pos = pos_2, level_one, NULL).`nested_struct_col` AS level_one | ||
FROM array_test AS t1, UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(t1.`repeated_struct_col`)) - 1)) AS pos | ||
CROSS JOIN UNNEST(t1.`repeated_struct_col`) AS level_one WITH OFFSET AS pos_2 | ||
WHERE | ||
pos = pos_2 | ||
OR ( | ||
pos > ( | ||
ARRAY_LENGTH(t1.`repeated_struct_col`) - 1 | ||
) | ||
AND pos_2 = ( | ||
ARRAY_LENGTH(t1.`repeated_struct_col`) - 1 | ||
) | ||
) | ||
) AS t0, UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(t0.`level_one`)) - 1)) AS pos | ||
CROSS JOIN UNNEST(t0.`level_one`) AS level_two WITH OFFSET AS pos_2 | ||
WHERE | ||
pos = pos_2 | ||
OR ( | ||
pos > ( | ||
ARRAY_LENGTH(t0.`level_one`) - 1 | ||
) | ||
AND pos_2 = ( | ||
ARRAY_LENGTH(t0.`level_one`) - 1 | ||
) | ||
) |
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
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
Oops, something went wrong.