Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BigQuery: Support Materialized Views (#3759)
- Loading branch information
Showing
7 changed files
with
331 additions
and
0 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
10 changes: 10 additions & 0 deletions
10
test/fixtures/dialects/bigquery/alter_materialized_view_set_options.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,10 @@ | ||
ALTER MATERIALIZED VIEW mydataset.my_mv | ||
SET OPTIONS ( | ||
enable_refresh=false | ||
); | ||
|
||
ALTER MATERIALIZED VIEW mydataset.my_mv | ||
SET OPTIONS ( | ||
friendly_name="my_mv", | ||
labels=[("org_unit", "development")] | ||
); |
61 changes: 61 additions & 0 deletions
61
test/fixtures/dialects/bigquery/alter_materialized_view_set_options.yml
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,61 @@ | ||
# YML test files are auto-generated from SQL files and should not be edited by | ||
# hand. To help enforce this, the "hash" field in the file must match a hash | ||
# computed by SQLFluff when running the tests. Please run | ||
# `python test/generate_parse_fixture_yml.py` to generate them after adding or | ||
# altering SQL files. | ||
_hash: f920358a40ae793dac230cb79235d4b77daac481e600270d82c487e513493ed0 | ||
file: | ||
- statement: | ||
alter_materialized_view_set_options_statement: | ||
- keyword: ALTER | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- keyword: SET | ||
- options_segment: | ||
keyword: OPTIONS | ||
bracketed: | ||
start_bracket: ( | ||
parameter: enable_refresh | ||
comparison_operator: | ||
raw_comparison_operator: '=' | ||
boolean_literal: 'false' | ||
end_bracket: ) | ||
- statement_terminator: ; | ||
- statement: | ||
alter_materialized_view_set_options_statement: | ||
- keyword: ALTER | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- keyword: SET | ||
- options_segment: | ||
keyword: OPTIONS | ||
bracketed: | ||
- start_bracket: ( | ||
- parameter: friendly_name | ||
- comparison_operator: | ||
raw_comparison_operator: '=' | ||
- quoted_literal: '"my_mv"' | ||
- comma: ',' | ||
- parameter: labels | ||
- comparison_operator: | ||
raw_comparison_operator: '=' | ||
- array_literal: | ||
start_square_bracket: '[' | ||
expression: | ||
bracketed: | ||
- start_bracket: ( | ||
- quoted_literal: '"org_unit"' | ||
- comma: ',' | ||
- quoted_literal: '"development"' | ||
- end_bracket: ) | ||
end_square_bracket: ']' | ||
- end_bracket: ) | ||
- statement_terminator: ; |
17 changes: 17 additions & 0 deletions
17
test/fixtures/dialects/bigquery/create_materialized_view.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,17 @@ | ||
CREATE MATERIALIZED VIEW mydataset.my_mv | ||
AS SELECT * FROM anotherdataset.mv_base_table; | ||
|
||
CREATE MATERIALIZED VIEW IF NOT EXISTS mydataset.my_mv | ||
AS SELECT * FROM anotherdataset.mv_base_table; | ||
|
||
CREATE MATERIALIZED VIEW mydataset.my_mv | ||
OPTIONS( | ||
friendly_name="my_mv" | ||
) | ||
AS SELECT * FROM anotherdataset.mv_base_table; | ||
|
||
CREATE MATERIALIZED VIEW mydataset.my_mv | ||
PARTITION BY DATE(x) | ||
CLUSTER BY y | ||
AS SELECT x, y | ||
FROM anotherdataset.mv_base_table; |
149 changes: 149 additions & 0 deletions
149
test/fixtures/dialects/bigquery/create_materialized_view.yml
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,149 @@ | ||
# YML test files are auto-generated from SQL files and should not be edited by | ||
# hand. To help enforce this, the "hash" field in the file must match a hash | ||
# computed by SQLFluff when running the tests. Please run | ||
# `python test/generate_parse_fixture_yml.py` to generate them after adding or | ||
# altering SQL files. | ||
_hash: fa0c77fc692915b62e59448c86e6a13dd1a72bec82c6e436dff5b7130f2a0076 | ||
file: | ||
- statement: | ||
create_materialized_view_statement: | ||
- keyword: CREATE | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- keyword: AS | ||
- select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
wildcard_expression: | ||
wildcard_identifier: | ||
star: '*' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
- naked_identifier: anotherdataset | ||
- dot: . | ||
- naked_identifier: mv_base_table | ||
- statement_terminator: ; | ||
- statement: | ||
create_materialized_view_statement: | ||
- keyword: CREATE | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- keyword: IF | ||
- keyword: NOT | ||
- keyword: EXISTS | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- keyword: AS | ||
- select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
wildcard_expression: | ||
wildcard_identifier: | ||
star: '*' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
- naked_identifier: anotherdataset | ||
- dot: . | ||
- naked_identifier: mv_base_table | ||
- statement_terminator: ; | ||
- statement: | ||
create_materialized_view_statement: | ||
- keyword: CREATE | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- options_segment: | ||
keyword: OPTIONS | ||
bracketed: | ||
start_bracket: ( | ||
parameter: friendly_name | ||
comparison_operator: | ||
raw_comparison_operator: '=' | ||
quoted_literal: '"my_mv"' | ||
end_bracket: ) | ||
- keyword: AS | ||
- select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
wildcard_expression: | ||
wildcard_identifier: | ||
star: '*' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
- naked_identifier: anotherdataset | ||
- dot: . | ||
- naked_identifier: mv_base_table | ||
- statement_terminator: ; | ||
- statement: | ||
create_materialized_view_statement: | ||
- keyword: CREATE | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- partition_by_segment: | ||
- keyword: PARTITION | ||
- keyword: BY | ||
- expression: | ||
function: | ||
function_name: | ||
function_name_identifier: DATE | ||
bracketed: | ||
start_bracket: ( | ||
expression: | ||
column_reference: | ||
naked_identifier: x | ||
end_bracket: ) | ||
- cluster_by_segment: | ||
- keyword: CLUSTER | ||
- keyword: BY | ||
- expression: | ||
column_reference: | ||
naked_identifier: y | ||
- keyword: AS | ||
- select_statement: | ||
select_clause: | ||
- keyword: SELECT | ||
- select_clause_element: | ||
column_reference: | ||
naked_identifier: x | ||
- comma: ',' | ||
- select_clause_element: | ||
column_reference: | ||
naked_identifier: y | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
- naked_identifier: anotherdataset | ||
- dot: . | ||
- naked_identifier: mv_base_table | ||
- statement_terminator: ; |
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,3 @@ | ||
DROP MATERIALIZED VIEW mydataset.my_mv; | ||
|
||
DROP MATERIALIZED VIEW IF EXISTS mydataset.my_mv; |
29 changes: 29 additions & 0 deletions
29
test/fixtures/dialects/bigquery/drop_materialized_view.yml
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,29 @@ | ||
# YML test files are auto-generated from SQL files and should not be edited by | ||
# hand. To help enforce this, the "hash" field in the file must match a hash | ||
# computed by SQLFluff when running the tests. Please run | ||
# `python test/generate_parse_fixture_yml.py` to generate them after adding or | ||
# altering SQL files. | ||
_hash: 023f2a8fc6cf7288d13cc3d91ec757da95570d47cfc90e3dca3f5abf0d2fff63 | ||
file: | ||
- statement: | ||
drop_materialized_view_statement: | ||
- keyword: DROP | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- statement_terminator: ; | ||
- statement: | ||
drop_materialized_view_statement: | ||
- keyword: DROP | ||
- keyword: MATERIALIZED | ||
- keyword: VIEW | ||
- keyword: IF | ||
- keyword: EXISTS | ||
- table_reference: | ||
- naked_identifier: mydataset | ||
- dot: . | ||
- naked_identifier: my_mv | ||
- statement_terminator: ; |