Skip to content

Commit

Permalink
feat!: keyword PATH -> OFFLINE_PATH (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
aceforeverd authored May 23, 2023
1 parent ca3cf22 commit 80f50d3
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 43 deletions.
12 changes: 6 additions & 6 deletions zetasql/parser/bison_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -7578,7 +7578,7 @@ keyword_as_identifier:
| "OUTFILE"
| "PARQUET"
| "HIVE"
| "PATH"
| "OFFLINE_PATH"
| "PERCENT"
| "PIVOT"
| "POLICIES"
Expand Down
2 changes: 1 addition & 1 deletion zetasql/parser/flex_tokenizer.l
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion zetasql/parser/keywords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
12 changes: 6 additions & 6 deletions zetasql/parser/parse_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ static absl::flat_hash_map<ASTNodeKind, std::string> 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<ASTNodeKind>(kind)))
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions zetasql/parser/parse_tree_manual.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<VisitResult> Accept(
NonRecursiveParseTreeVisitor* visitor) const override;
Expand All @@ -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<VisitResult> Accept(
NonRecursiveParseTreeVisitor* visitor) const override;
Expand Down
10 changes: 5 additions & 5 deletions zetasql/parser/testdata/alter_set_options.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
^
==
Expand Down
2 changes: 1 addition & 1 deletion zetasql/parser/testdata/alter_table_drop_column.test
Original file line number Diff line number Diff line change
@@ -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;
^

Expand Down
2 changes: 1 addition & 1 deletion zetasql/parser/testdata/alter_table_drop_constraint.test
Original file line number Diff line number Diff line change
@@ -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;
^

Expand Down
24 changes: 12 additions & 12 deletions zetasql/parser/testdata/alter_table_path.test
Original file line number Diff line number Diff line change
@@ -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'
==
8 changes: 4 additions & 4 deletions zetasql/parser/unparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions zetasql/parser/unparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 80f50d3

Please sign in to comment.