Skip to content

Commit

Permalink
Merge pull request #329 from kitta65/feature/spark-stored-procedure
Browse files Browse the repository at this point in the history
support spark stored procedure
  • Loading branch information
kitta65 authored Mar 22, 2024
2 parents 7ccbe10 + 4766f13 commit 287aa88
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?);
Expand Down
40 changes: 40 additions & 0 deletions src/parser/tests/tests_ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)),
Expand Down
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 287aa88

Please sign in to comment.