From 8af5c329c57c3e39e3ad8e3d46a939fbfdd8db65 Mon Sep 17 00:00:00 2001 From: dr666m1 <26474260+kitta65@users.noreply.github.com> Date: Sat, 23 Nov 2024 22:56:30 +0900 Subject: [PATCH 1/3] add TODO comments --- src/parser.rs | 1 + src/parser/tests/tests_ddl.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index ae0005e..c62c026 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2025,6 +2025,7 @@ impl Parser { // ----- DDL ----- fn parse_create_schema_statement(&mut self, semicolon: bool) -> BQ2CSTResult { let mut create = self.construct_node(NodeType::CreateSchemaStatement)?; + // TODO allow external schema self.next_token()?; // -> SCHEMA create.push_node("what", self.construct_node(NodeType::Keyword)?); if self.get_token(1)?.is("IF") { diff --git a/src/parser/tests/tests_ddl.rs b/src/parser/tests/tests_ddl.rs index 47a84bd..0d576e4 100644 --- a/src/parser/tests/tests_ddl.rs +++ b/src/parser/tests/tests_ddl.rs @@ -74,6 +74,7 @@ what: ", 0, )), + // TODO add test of external schema // ----- CREATE SEARCH INDEX statement ----- Box::new(SuccessTestCase::new( "\ From 6b9bee60f1ff862b3cf6f162cbdfefc7d5f1aa71 Mon Sep 17 00:00:00 2001 From: dr666m1 <26474260+kitta65@users.noreply.github.com> Date: Sun, 24 Nov 2024 10:21:18 +0900 Subject: [PATCH 2/3] allow external keyword --- src/parser.rs | 6 +++++- src/parser/tests/tests_ddl.rs | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index c62c026..d3ab10a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2025,7 +2025,10 @@ impl Parser { // ----- DDL ----- fn parse_create_schema_statement(&mut self, semicolon: bool) -> BQ2CSTResult { let mut create = self.construct_node(NodeType::CreateSchemaStatement)?; - // TODO allow external schema + 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") { @@ -2048,6 +2051,7 @@ impl Parser { default.push_node("next_keyword", collate); create.push_node("default_collate", default); } + // TODO with connection if self.get_token(1)?.is("OPTIONS") { self.next_token()?; // OPTIONS create.push_node("options", self.parse_keyword_with_grouped_exprs(false)?); diff --git a/src/parser/tests/tests_ddl.rs b/src/parser/tests/tests_ddl.rs index 0d576e4..0c8c461 100644 --- a/src/parser/tests/tests_ddl.rs +++ b/src/parser/tests/tests_ddl.rs @@ -74,7 +74,21 @@ what: ", 0, )), - // TODO add test of external schema + Box::new(SuccessTestCase::new( + "\ +CREATE EXTERNAL SCHEMA dataset_name +", + "\ +self: CREATE (CreateSchemaStatement) +external: + self: EXTERNAL (Keyword) +ident: + self: dataset_name (Identifier) +what: + self: SCHEMA (Keyword) +", + 0, + )), // ----- CREATE SEARCH INDEX statement ----- Box::new(SuccessTestCase::new( "\ From 8936d0e48ceeed4323699e5140f42ea3ab7383c2 Mon Sep 17 00:00:00 2001 From: dr666m1 <26474260+kitta65@users.noreply.github.com> Date: Sun, 24 Nov 2024 10:28:19 +0900 Subject: [PATCH 3/3] parse with connection clause --- src/parser.rs | 5 ++++- src/parser/tests/tests_ddl.rs | 7 +++++++ src/types.rs | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/parser.rs b/src/parser.rs index d3ab10a..20bc2ec 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2051,7 +2051,10 @@ impl Parser { default.push_node("next_keyword", collate); create.push_node("default_collate", default); } - // TODO with connection + 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)?); diff --git a/src/parser/tests/tests_ddl.rs b/src/parser/tests/tests_ddl.rs index 0c8c461..9e73937 100644 --- a/src/parser/tests/tests_ddl.rs +++ b/src/parser/tests/tests_ddl.rs @@ -77,6 +77,7 @@ what: Box::new(SuccessTestCase::new( "\ CREATE EXTERNAL SCHEMA dataset_name +WITH CONNECTION connection_name ", "\ self: CREATE (CreateSchemaStatement) @@ -86,6 +87,12 @@ 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, )), diff --git a/src/types.rs b/src/types.rs index cc20bd6..591da91 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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; }; };