Skip to content

Commit

Permalink
Merge pull request #451 from kitta65/feature/issue-430
Browse files Browse the repository at this point in the history
Feature/issue 430
  • Loading branch information
kitta65 authored Nov 24, 2024
2 parents 37bed8d + 9c22db0 commit 3c8421d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,10 @@ impl Parser {
// ----- DDL -----
fn parse_create_schema_statement(&mut self, semicolon: bool) -> BQ2CSTResult<Node> {
let mut create = self.construct_node(NodeType::CreateSchemaStatement)?;
if self.get_token(1)?.is("EXTERNAL") {
self.next_token()?; // -> EXTERNAL
create.push_node("external", self.construct_node(NodeType::Keyword)?);
}
self.next_token()?; // -> SCHEMA
create.push_node("what", self.construct_node(NodeType::Keyword)?);
if self.get_token(1)?.is("IF") {
Expand All @@ -2047,6 +2051,10 @@ impl Parser {
default.push_node("next_keyword", collate);
create.push_node("default_collate", default);
}
if self.get_token(1)?.is("WITH") && self.get_token(2)?.is("CONNECTION") {
self.next_token()?; // -> WITH
create.push_node("with_connection", self.parse_with_connection_clause()?);
}
if self.get_token(1)?.is("OPTIONS") {
self.next_token()?; // OPTIONS
create.push_node("options", self.parse_keyword_with_grouped_exprs(false)?);
Expand Down
22 changes: 22 additions & 0 deletions src/parser/tests/tests_ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ ident:
self: dataset_name (Identifier)
what:
self: SCHEMA (Keyword)
",
0,
)),
Box::new(SuccessTestCase::new(
"\
CREATE EXTERNAL SCHEMA dataset_name
WITH CONNECTION connection_name
",
"\
self: CREATE (CreateSchemaStatement)
external:
self: EXTERNAL (Keyword)
ident:
self: dataset_name (Identifier)
what:
self: SCHEMA (Keyword)
with_connection:
self: WITH (KeywordSequence)
next_keyword:
self: CONNECTION (KeywordWithExpr)
expr:
self: connection_name (Identifier)
",
0,
)),
Expand Down
2 changes: 2 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,12 @@ export type CreateRowAccessPolicyStatement = XXXStatement & {
export type CreateSchemaStatement = XXXStatement & {
node_type: "CreateSchemaStatement";
children: {
external?: NodeChild;
what: NodeChild;
if_not_exists?: NodeVecChild;
ident: NodeChild;
default_collate: NodeChild;
with_connection?: NodeChild;
options?: NodeChild;
};
};
Expand Down

0 comments on commit 3c8421d

Please sign in to comment.