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] 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; }; };