From 4766f13f086615ca92a0128df9f69a99b9fe09de Mon Sep 17 00:00:00 2001 From: dr666m1 <26474260+kitta65@users.noreply.github.com> Date: Fri, 22 Mar 2024 23:27:05 +0900 Subject: [PATCH] support spark stored procedure --- src/parser.rs | 11 ++++++++++ src/parser/tests/tests_ddl.rs | 40 +++++++++++++++++++++++++++++++++++ src/types.rs | 1 + 3 files changed, 52 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index e1d7811..3e8d881 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2383,6 +2383,17 @@ impl Parser { "group", self.parse_grouped_type_declaration_or_constraints(true)?, ); + if self.get_token(1)?.is("EXTERNAL") { + self.next_token()?; // -> EXTERNAL + let mut external = self.construct_node(NodeType::KeywordSequence)?; + self.next_token()?; // -> SECURITY + let mut security = self.construct_node(NodeType::KeywordSequence)?; + self.next_token()?; // -> INVOKER + let external_security = self.construct_node(NodeType::Keyword)?; + security.push_node("next_keyword", external_security); + external.push_node("next_keyword", security); + create.push_node("external", external); + } if self.get_token(1)?.is("WITH") { self.next_token()?; // -> WITH create.push_node("with_connection", self.parse_with_connection_clause()?); diff --git a/src/parser/tests/tests_ddl.rs b/src/parser/tests/tests_ddl.rs index ff900ca..6d7dbe9 100644 --- a/src/parser/tests/tests_ddl.rs +++ b/src/parser/tests/tests_ddl.rs @@ -1803,6 +1803,46 @@ with_connection: self: CONNECTION (KeywordWithExpr) expr: self: connection_ident (Identifier) +", + 0, + )), + Box::new(SuccessTestCase::new( + "\ +CREATE PROCEDURE procedure_ident() +EXTERNAL SECURITY INVOKER +WITH CONNECTION connection_ident +LANGUAGE python AS 'code' +", + "\ +self: CREATE (CreateProcedureStatement) +as: + self: AS (KeywordWithExpr) + expr: + self: 'code' (StringLiteral) +external: + self: EXTERNAL (KeywordSequence) + next_keyword: + self: SECURITY (KeywordSequence) + next_keyword: + self: INVOKER (Keyword) +group: + self: ( (GroupedTypeDeclarationOrConstraints) + rparen: + self: ) (Symbol) +ident: + self: procedure_ident (Identifier) +language: + self: LANGUAGE (KeywordWithExpr) + expr: + self: python (Identifier) +what: + self: PROCEDURE (Keyword) +with_connection: + self: WITH (KeywordSequence) + next_keyword: + self: CONNECTION (KeywordWithExpr) + expr: + self: connection_ident (Identifier) ", 0, )), diff --git a/src/types.rs b/src/types.rs index 180507b..d11b8ef 100644 --- a/src/types.rs +++ b/src/types.rs @@ -610,6 +610,7 @@ export type CreateProcedureStatement = XXXStatement & { if_not_exists?: NodeVecChild; ident: NodeChild; group: NodeChild; + external?: NodeChild; with_connection?: NodeChild; options?: NodeChild; language?: NodeChild;