diff --git a/zetasql/parser/bison_parser.y b/zetasql/parser/bison_parser.y index bb1c7dcca..11389c8c6 100644 --- a/zetasql/parser/bison_parser.y +++ b/zetasql/parser/bison_parser.y @@ -8297,9 +8297,9 @@ on_path_expression: ; deploy_statement: - "DEPLOY" opt_if_not_exists identifier unterminated_sql_statement + "DEPLOY" opt_if_not_exists identifier opt_options_list unterminated_sql_statement { - auto deploy_stmt = MAKE_NODE(ASTDeployStatement, @$, {$3, $4}); + auto deploy_stmt = MAKE_NODE(ASTDeployStatement, @$, {$3, $4, $5}); deploy_stmt->set_is_if_not_exists($2); $$ = deploy_stmt; } diff --git a/zetasql/parser/parse_tree_manual.h b/zetasql/parser/parse_tree_manual.h index 53314248a..66c0f385b 100644 --- a/zetasql/parser/parse_tree_manual.h +++ b/zetasql/parser/parse_tree_manual.h @@ -655,6 +655,7 @@ class ASTDeployStatement final : public ASTStatement { const ASTIdentifier* name() const { return name_; } const ASTStatement* stmt() const { return stmt_; } + const ASTOptionsList* options_list() const { return options_list_; } bool is_if_not_exists() const { return is_if_not_exists_; } void set_is_if_not_exists(bool value) { is_if_not_exists_ = value; } @@ -663,11 +664,13 @@ class ASTDeployStatement final : public ASTStatement { void InitFields() final { FieldLoader fl(this); fl.AddRequired(&name_); + fl.AddOptional(&options_list_, AST_OPTIONS_LIST); fl.AddRequired(&stmt_); } const ASTIdentifier* name_ = nullptr; const ASTStatement* stmt_ = nullptr; bool is_if_not_exists_ = false; + const ASTOptionsList* options_list_ = nullptr; }; class ASTStopStatement final : public ASTStatement { diff --git a/zetasql/parser/testdata/deploy.test b/zetasql/parser/testdata/deploy.test index 25e4a990b..26ef9bdc5 100644 --- a/zetasql/parser/testdata/deploy.test +++ b/zetasql/parser/testdata/deploy.test @@ -14,6 +14,27 @@ SELECT 1 == +DEPLOY IF NOT EXISTS data_service_1 OPTIONS(long_windows="w1:100,w2:100s") SELECT 1; +-- +DeployStatement [0-83] + Identifier(data_service_1) [21-35] + OptionsList [43-74] + OptionsEntry [44-73] + Identifier(long_windows) [44-56] + StringLiteral("w1:100,w2:100s") [57-73] + QueryStatement [75-83] + Query [75-83] + Select [75-83] + SelectList [82-83] + SelectColumn [82-83] + IntLiteral(1) [82-83] +-- +DEPLOY IF NOT EXISTS data_service_1 OPTIONS(long_windows = "w1:100,w2:100s") +SELECT + 1 +== + + DEPLOY deploy create table t1 (a int32, b string); -- DeployStatement [0-49] diff --git a/zetasql/parser/unparser.cc b/zetasql/parser/unparser.cc index d4a81daf4..c21b8d203 100644 --- a/zetasql/parser/unparser.cc +++ b/zetasql/parser/unparser.cc @@ -884,6 +884,11 @@ void Unparser::visitASTDeployStatement(const ASTDeployStatement *node, void *dat print("IF NOT EXISTS"); } node->name()->Accept(this, data); + + if (node->options_list() != nullptr) { + print("OPTIONS"); + node->options_list()->Accept(this, data); + } node->stmt()->Accept(this, data); }