From 80f50d3aef8ad3433c9d28844345181d0242f302 Mon Sep 17 00:00:00 2001 From: aceforeverd Date: Tue, 23 May 2023 18:55:41 +0800 Subject: [PATCH] feat!: keyword PATH -> OFFLINE_PATH (#50) --- zetasql/parser/bison_parser.y | 12 +++++----- zetasql/parser/flex_tokenizer.l | 2 +- zetasql/parser/keywords.cc | 2 +- zetasql/parser/parse_tree.cc | 12 +++++----- zetasql/parser/parse_tree_manual.h | 8 +++---- .../parser/testdata/alter_set_options.test | 10 ++++---- .../testdata/alter_table_drop_column.test | 2 +- .../testdata/alter_table_drop_constraint.test | 2 +- zetasql/parser/testdata/alter_table_path.test | 24 +++++++++---------- zetasql/parser/unparser.cc | 8 +++---- zetasql/parser/unparser.h | 4 ++-- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/zetasql/parser/bison_parser.y b/zetasql/parser/bison_parser.y index 04963ed31..4d894a5b3 100644 --- a/zetasql/parser/bison_parser.y +++ b/zetasql/parser/bison_parser.y @@ -884,7 +884,7 @@ using zetasql::ASTDropStatement; %token KW_OUTFILE "OUTFILE" %token KW_PARQUET "PARQUET" %token KW_HIVE "HIVE" -%token KW_PATH "PATH" +%token KW_OFFLINE_PATH "OFFLINE_PATH" %token KW_PERCENT "PERCENT" %token KW_PIVOT "PIVOT" %token KW_POLICIES "POLICIES" @@ -1673,14 +1673,14 @@ alter_action: node->set_is_if_exists($3); $$ = node; } - | "ADD" "PATH" string_literal + | "ADD" "OFFLINE_PATH" string_literal { - auto* node = MAKE_NODE(ASTAddPathAction, @$, {$3}); + auto* node = MAKE_NODE(ASTAddOfflinePathAction, @$, {$3}); $$ = node; } - | "DROP" "PATH" string_literal + | "DROP" "OFFLINE_PATH" string_literal { - auto* node = MAKE_NODE(ASTDropPathAction, @$, {$3}); + auto* node = MAKE_NODE(ASTDropOfflinePathAction, @$, {$3}); $$ = node; } | "ADD" "COLUMN" opt_if_not_exists table_column_definition @@ -7578,7 +7578,7 @@ keyword_as_identifier: | "OUTFILE" | "PARQUET" | "HIVE" - | "PATH" + | "OFFLINE_PATH" | "PERCENT" | "PIVOT" | "POLICIES" diff --git a/zetasql/parser/flex_tokenizer.l b/zetasql/parser/flex_tokenizer.l index 55e965b64..88e6aa606 100644 --- a/zetasql/parser/flex_tokenizer.l +++ b/zetasql/parser/flex_tokenizer.l @@ -573,7 +573,7 @@ outer { return BisonParserImpl::token::KW_OUTER; } over { return BisonParserImpl::token::KW_OVER; } parquet { return BisonParserImpl::token::KW_PARQUET; } partition { return BisonParserImpl::token::KW_PARTITION; } -path { return BisonParserImpl::token::KW_PATH; } +offline_path { return BisonParserImpl::token::KW_OFFLINE_PATH; } percent { return BisonParserImpl::token::KW_PERCENT; } policies { return BisonParserImpl::token::KW_POLICIES; } policy { return BisonParserImpl::token::KW_POLICY; } diff --git a/zetasql/parser/keywords.cc b/zetasql/parser/keywords.cc index 825cfcc77..fc1e1e858 100644 --- a/zetasql/parser/keywords.cc +++ b/zetasql/parser/keywords.cc @@ -226,7 +226,7 @@ constexpr KeywordInfoPOD kAllKeywords[] = { {"outer", KW_OUTER, KeywordInfo::kReserved}, {"over", KW_OVER, KeywordInfo::kReserved}, {"parquet", KW_PARQUET}, - {"path", KW_PATH}, + {"offline_path", KW_OFFLINE_PATH}, {"hive", KW_HIVE}, {"partition", KW_PARTITION, KeywordInfo::kReserved}, {"percent", KW_PERCENT}, diff --git a/zetasql/parser/parse_tree.cc b/zetasql/parser/parse_tree.cc index 0ec87d521..85923b82b 100644 --- a/zetasql/parser/parse_tree.cc +++ b/zetasql/parser/parse_tree.cc @@ -366,8 +366,8 @@ static absl::flat_hash_map CreateNodeNamesMap() { map[AST_WINDOW_ATTRIBUTE_INST_NOT_IN_WINDOW] = "WindowAttributeInstNotInWindow"; map[AST_WINDOW_ATTRIBUTE_LIST] = "WindowAttributeList"; map[AST_LIKE_TABLE_CLAUSE] = "LikeTableClause"; - map[AST_ADD_PATH_ACTION] = "AddPathAction"; - map[AST_DROP_PATH_ACTION] = "DropPathAction"; + map[AST_ADD_PATH_ACTION] = "AddOfflinePathAction"; + map[AST_DROP_PATH_ACTION] = "DropOfflinePathAction"; for (int kind = kFirstASTNodeKind; kind <= kLastASTNodeKind; ++kind) { ZETASQL_DCHECK(zetasql_base::ContainsKey(map, static_cast(kind))) @@ -1545,12 +1545,12 @@ std::string ASTAddColumnAction::GetSQLForAlterAction() const { return "ADD COLUMN"; } -std::string ASTAddPathAction::GetSQLForAlterAction() const { - return "ADD PATH"; +std::string ASTAddOfflinePathAction::GetSQLForAlterAction() const { + return "ADD OFFLINE_PATH"; } -std::string ASTDropPathAction::GetSQLForAlterAction() const { - return "DROP PATH"; +std::string ASTDropOfflinePathAction::GetSQLForAlterAction() const { + return "DROP OFFLINE_PATH"; } std::string ASTColumnPosition::SingleNodeDebugString() const { diff --git a/zetasql/parser/parse_tree_manual.h b/zetasql/parser/parse_tree_manual.h index 7c748a4e3..aff73048e 100644 --- a/zetasql/parser/parse_tree_manual.h +++ b/zetasql/parser/parse_tree_manual.h @@ -7197,11 +7197,11 @@ class ASTAlterConstraintSetOptionsAction final : public ASTAlterAction { }; // ALTER table action for "ADD PATH" clause -class ASTAddPathAction final : public ASTAlterAction { +class ASTAddOfflinePathAction final : public ASTAlterAction { public: static constexpr ASTNodeKind kConcreteNodeKind = AST_ADD_PATH_ACTION; - ASTAddPathAction() : ASTAlterAction(kConcreteNodeKind) {} + ASTAddOfflinePathAction() : ASTAlterAction(kConcreteNodeKind) {} void Accept(ParseTreeVisitor* visitor, void* data) const override; zetasql_base::StatusOr Accept( NonRecursiveParseTreeVisitor* visitor) const override; @@ -7220,11 +7220,11 @@ class ASTAddPathAction final : public ASTAlterAction { }; // ALTER table action for "DROP PATH" clause -class ASTDropPathAction final : public ASTAlterAction { +class ASTDropOfflinePathAction final : public ASTAlterAction { public: static constexpr ASTNodeKind kConcreteNodeKind = AST_DROP_PATH_ACTION; - ASTDropPathAction() : ASTAlterAction(kConcreteNodeKind) {} + ASTDropOfflinePathAction() : ASTAlterAction(kConcreteNodeKind) {} void Accept(ParseTreeVisitor* visitor, void* data) const override; zetasql_base::StatusOr Accept( NonRecursiveParseTreeVisitor* visitor) const override; diff --git a/zetasql/parser/testdata/alter_set_options.test b/zetasql/parser/testdata/alter_set_options.test index bc56e9f23..9292d6da4 100644 --- a/zetasql/parser/testdata/alter_set_options.test +++ b/zetasql/parser/testdata/alter_set_options.test @@ -69,31 +69,31 @@ ALTER {{DATABASE|SCHEMA|TABLE|VIEW|MATERIALIZED VIEW}} foo drop; -- ALTERNATION GROUP: DATABASE -- -ERROR: Syntax error: Expected keyword COLUMN or keyword CONSTRAINT or keyword PATH but got ";" [at 1:24] +ERROR: Syntax error: Expected OFFLINE_PATH or keyword COLUMN or keyword CONSTRAINT but got ";" [at 1:24] ALTER DATABASE foo drop; ^ -- ALTERNATION GROUP: SCHEMA -- -ERROR: Syntax error: Expected keyword COLUMN or keyword CONSTRAINT or keyword PATH but got ";" [at 1:22] +ERROR: Syntax error: Expected OFFLINE_PATH or keyword COLUMN or keyword CONSTRAINT but got ";" [at 1:22] ALTER SCHEMA foo drop; ^ -- ALTERNATION GROUP: TABLE -- -ERROR: Syntax error: Expected keyword COLUMN or keyword CONSTRAINT or keyword PATH but got ";" [at 1:21] +ERROR: Syntax error: Expected OFFLINE_PATH or keyword COLUMN or keyword CONSTRAINT but got ";" [at 1:21] ALTER TABLE foo drop; ^ -- ALTERNATION GROUP: VIEW -- -ERROR: Syntax error: Expected keyword COLUMN or keyword CONSTRAINT or keyword PATH but got ";" [at 1:20] +ERROR: Syntax error: Expected OFFLINE_PATH or keyword COLUMN or keyword CONSTRAINT but got ";" [at 1:20] ALTER VIEW foo drop; ^ -- ALTERNATION GROUP: MATERIALIZED VIEW -- -ERROR: Syntax error: Expected keyword COLUMN or keyword CONSTRAINT or keyword PATH but got ";" [at 1:33] +ERROR: Syntax error: Expected OFFLINE_PATH or keyword COLUMN or keyword CONSTRAINT but got ";" [at 1:33] ALTER MATERIALIZED VIEW foo drop; ^ == diff --git a/zetasql/parser/testdata/alter_table_drop_column.test b/zetasql/parser/testdata/alter_table_drop_column.test index 07ab7a22e..96524cd47 100644 --- a/zetasql/parser/testdata/alter_table_drop_column.test +++ b/zetasql/parser/testdata/alter_table_drop_column.test @@ -1,6 +1,6 @@ alter table foo.bar drop; -- -ERROR: Syntax error: Expected keyword COLUMN or keyword CONSTRAINT or keyword PATH but got ";" [at 1:25] +ERROR: Syntax error: Expected OFFLINE_PATH or keyword COLUMN or keyword CONSTRAINT but got ";" [at 1:25] alter table foo.bar drop; ^ diff --git a/zetasql/parser/testdata/alter_table_drop_constraint.test b/zetasql/parser/testdata/alter_table_drop_constraint.test index ba4698094..0c38f10e8 100644 --- a/zetasql/parser/testdata/alter_table_drop_constraint.test +++ b/zetasql/parser/testdata/alter_table_drop_constraint.test @@ -1,6 +1,6 @@ alter table foo.bar drop; -- -ERROR: Syntax error: Expected keyword COLUMN or keyword CONSTRAINT or keyword PATH but got ";" [at 1:25] +ERROR: Syntax error: Expected OFFLINE_PATH or keyword COLUMN or keyword CONSTRAINT but got ";" [at 1:25] alter table foo.bar drop; ^ diff --git a/zetasql/parser/testdata/alter_table_path.test b/zetasql/parser/testdata/alter_table_path.test index 5df53c52d..f3fccd34d 100644 --- a/zetasql/parser/testdata/alter_table_path.test +++ b/zetasql/parser/testdata/alter_table_path.test @@ -1,25 +1,25 @@ # ALTER TABLE to add column. -ALTER TABLE foo ADD PATH 'this is a path'; +ALTER TABLE foo ADD OFFLINE_PATH 'this is a path'; -- -AlterTableStatement [0-41] +AlterTableStatement [0-49] PathExpression [12-15] Identifier(foo) [12-15] - AlterActionList [16-41] - AddPathAction [16-41] - StringLiteral('this is a path') [25-41] + AlterActionList [16-49] + AddOfflinePathAction [16-49] + StringLiteral('this is a path') [33-49] -- -ALTER TABLE foo ADD PATH 'this is a path' +ALTER TABLE foo ADD OFFLINE_PATH 'this is a path' == # ALTER TABLE to drop column. -ALTER TABLE foo drop PATH 'nothing'; +ALTER TABLE foo drop OFFLINE_PATH 'nothing'; -- -AlterTableStatement [0-35] +AlterTableStatement [0-43] PathExpression [12-15] Identifier(foo) [12-15] - AlterActionList [16-35] - DropPathAction [16-35] - StringLiteral('nothing') [26-35] + AlterActionList [16-43] + DropOfflinePathAction [16-43] + StringLiteral('nothing') [34-43] -- -ALTER TABLE foo DROP PATH 'nothing' +ALTER TABLE foo DROP OFFLINE_PATH 'nothing' == diff --git a/zetasql/parser/unparser.cc b/zetasql/parser/unparser.cc index b8f8d02cd..682eefa95 100644 --- a/zetasql/parser/unparser.cc +++ b/zetasql/parser/unparser.cc @@ -3493,14 +3493,14 @@ void Unparser::visitASTRaiseStatement(const ASTRaiseStatement* node, } } -void Unparser::visitASTAddPathAction(const ASTAddPathAction *node, void *data) { - print("ADD PATH"); +void Unparser::visitASTAddOfflinePathAction(const ASTAddOfflinePathAction *node, void *data) { + print("ADD OFFLINE_PATH"); node->path()->Accept(this, data); } -void Unparser::visitASTDropPathAction(const ASTDropPathAction *node, +void Unparser::visitASTDropOfflinePathAction(const ASTDropOfflinePathAction *node, void *data) { - print("DROP PATH"); + print("DROP OFFLINE_PATH"); node->path()->Accept(this, data); } diff --git a/zetasql/parser/unparser.h b/zetasql/parser/unparser.h index b96eb461d..169c582ad 100644 --- a/zetasql/parser/unparser.h +++ b/zetasql/parser/unparser.h @@ -646,8 +646,8 @@ class Unparser : public ParseTreeVisitor { void visitASTRaiseStatement(const ASTRaiseStatement* node, void* data) override; - void visitASTAddPathAction(const ASTAddPathAction *node, void *data) override; - void visitASTDropPathAction(const ASTDropPathAction *node, + void visitASTAddOfflinePathAction(const ASTAddOfflinePathAction *node, void *data) override; + void visitASTDropOfflinePathAction(const ASTDropOfflinePathAction *node, void *data) override; protected: