Skip to content

Commit

Permalink
fix #315
Browse files Browse the repository at this point in the history
  • Loading branch information
kitta65 committed Mar 2, 2024
1 parent 998b41b commit 15dd6f8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2236,10 +2236,24 @@ impl Parser {
}
if self.get_token(1)?.is("AS") {
self.next_token()?; // -> AS
let mut as_ = self.construct_node(NodeType::KeywordWithStatement)?;
self.next_token()?; // -> SELECT
as_.push_node("stmt", self.parse_select_statement(false, true)?);
create.push_node("as", as_)
if self.get_token(1)?.is("REPLICA") {
let mut as_ = self.construct_node(NodeType::KeywordSequence)?;
self.next_token()?; // -> REPLICA
let mut replica = self.construct_node(NodeType::KeywordSequence)?;
self.next_token()?; // -> OF
let mut of = self.construct_node(NodeType::KeywordWithExpr)?;
self.next_token()?; // -> ident

of.push_node("expr", self.parse_identifier()?);
replica.push_node("next_keyword", of);
as_.push_node("next_keyword", replica);
create.push_node("as", as_)
} else {
let mut as_ = self.construct_node(NodeType::KeywordWithStatement)?;
self.next_token()?; // -> SELECT
as_.push_node("stmt", self.parse_select_statement(false, true)?);
create.push_node("as", as_)
}
}
if self.get_token(1)?.is(";") && semicolon {
self.next_token()?; // -> ;
Expand Down
25 changes: 25 additions & 0 deletions src/parser/tests/tests_ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,31 @@ ident:
self: viewname (Identifier)
what:
self: VIEW (Keyword)
",
0,
)),
// REPLICA
Box::new(SuccessTestCase::new(
"\
CREATE MATERIALIZED VIEW ident1
AS REPLICA OF ident2
",
"\
self: CREATE (CreateViewStatement)
as:
self: AS (KeywordSequence)
next_keyword:
self: REPLICA (KeywordSequence)
next_keyword:
self: OF (KeywordWithExpr)
expr:
self: ident2 (Identifier)
ident:
self: ident1 (Identifier)
materialized:
self: MATERIALIZED (Keyword)
what:
self: VIEW (Keyword)
",
0,
)),
Expand Down

0 comments on commit 15dd6f8

Please sign in to comment.