Skip to content

Commit

Permalink
Support CREATE OR REPLACE MATERIALIZED VIEW
Browse files Browse the repository at this point in the history
  • Loading branch information
davetapley committed Nov 16, 2022
1 parent 3e3d746 commit e8cf71b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sqlfluff/dialects/dialect_postgres.py
Expand Up @@ -2029,6 +2029,7 @@ class CreateMaterializedViewStatementSegment(BaseSegment):

match_grammar = Sequence(
"CREATE",
Sequence("OR", "REPLACE", optional=True),
"MATERIALIZED",
"VIEW",
Ref("IfNotExistsGrammar", optional=True),
Expand Down
Expand Up @@ -150,4 +150,8 @@ CREATE MATERIALIZED VIEW my_mat_view
WITH (left.right)
AS
SELECT a
FROM my_table;

CREATE OR REPLACE MATERIALIZED VIEW my_mat_view AS
SELECT a
FROM my_table;
Expand Up @@ -3,7 +3,7 @@
# 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: 372bd8f828b87dd66ddcf9a78448d50ea8a681bef794b750256f3786a988f06e
_hash: 241ca7aedfaff431b1ffae209bc65103e8caf6896b36324a8d4fb38b27c4bfb4
file:
- statement:
create_materialized_view_statement:
Expand Down Expand Up @@ -704,3 +704,27 @@ file:
table_reference:
naked_identifier: my_table
- statement_terminator: ;
- statement:
create_materialized_view_statement:
- keyword: CREATE
- keyword: OR
- keyword: REPLACE
- keyword: MATERIALIZED
- keyword: VIEW
- table_reference:
naked_identifier: my_mat_view
- keyword: AS
- select_statement:
select_clause:
keyword: SELECT
select_clause_element:
column_reference:
naked_identifier: a
from_clause:
keyword: FROM
from_expression:
from_expression_element:
table_expression:
table_reference:
naked_identifier: my_table
- statement_terminator: ;

0 comments on commit e8cf71b

Please sign in to comment.