This is an automated email from the ASF dual-hosted git repository. ayushsaxena pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push: new dea968ff6b6 HIVE-28226: Split Replication Commands from HiveParser.g. (#5220). (Ayush Saxena, reviewed by Butao Zhang) dea968ff6b6 is described below commit dea968ff6b601a32944acdc8987f5089e7492cad Author: Ayush Saxena <ayushsax...@apache.org> AuthorDate: Mon Apr 29 09:53:09 2024 +0530 HIVE-28226: Split Replication Commands from HiveParser.g. (#5220). (Ayush Saxena, reviewed by Butao Zhang) --- .../org/apache/hadoop/hive/ql/parse/HiveParser.g | 67 +------------ .../apache/hadoop/hive/ql/parse/ReplClauseParser.g | 110 +++++++++++++++++++++ 2 files changed, 111 insertions(+), 66 deletions(-) diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g index f128666d3cf..de6cf2c5efd 100644 --- a/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g +++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g @@ -25,7 +25,7 @@ backtrack=false; k=3; } -import AlterClauseParser, SelectClauseParser, FromClauseParser, IdentifiersParser, ResourcePlanParser, CreateDDLParser, PrepareStatementParser; +import AlterClauseParser, SelectClauseParser, FromClauseParser, IdentifiersParser, ResourcePlanParser, CreateDDLParser, PrepareStatementParser, ReplClauseParser; tokens { TOK_INSERT; @@ -977,13 +977,6 @@ loadStatement -> ^(TOK_LOAD $path $tab $islocal? $isoverwrite? inputFileFormat?) ; -replicationClause -@init { pushMsg("replication clause", state); } -@after { popMsg(state); } - : KW_FOR (isMetadataOnly=KW_METADATA)? KW_REPLICATION LPAREN (replId=StringLiteral) RPAREN - -> ^(TOK_REPLICATION $replId $isMetadataOnly?) - ; - exportStatement @init { pushMsg("export statement", state); } @after { popMsg(state); } @@ -1004,64 +997,6 @@ importStatement -> ^(TOK_IMPORT $path $tab? $ext? tableLocation?) ; -replDumpStatement -@init { pushMsg("Replication dump statement", state); } -@after { popMsg(state); } - : KW_REPL KW_DUMP - (dbPolicy=replDbPolicy) - (KW_REPLACE oldDbPolicy=replDbPolicy)? - (KW_WITH replConf=replConfigs)? - -> ^(TOK_REPL_DUMP $dbPolicy ^(TOK_REPLACE $oldDbPolicy)? $replConf?) - ; - -replDbPolicy -@init { pushMsg("Repl dump DB replication policy", state); } -@after { popMsg(state); } - : - (dbName=identifier) (DOT tablePolicy=replTableLevelPolicy)? -> $dbName $tablePolicy? - ; - -replLoadStatement -@init { pushMsg("Replication load statement", state); } -@after { popMsg(state); } - : KW_REPL KW_LOAD - (sourceDbPolicy=replDbPolicy) - (KW_INTO dbName=identifier)? - (KW_WITH replConf=replConfigs)? - -> ^(TOK_REPL_LOAD $sourceDbPolicy ^(TOK_DBNAME $dbName)? $replConf?) - ; - -replConfigs -@init { pushMsg("Repl configurations", state); } -@after { popMsg(state); } - : - LPAREN replConfigsList RPAREN -> ^(TOK_REPL_CONFIG replConfigsList) - ; - -replConfigsList -@init { pushMsg("Repl configurations list", state); } -@after { popMsg(state); } - : - keyValueProperty (COMMA keyValueProperty)* -> ^(TOK_REPL_CONFIG_LIST keyValueProperty+) - ; - -replTableLevelPolicy -@init { pushMsg("Replication table level policy definition", state); } -@after { popMsg(state); } - : - ((replTablesIncludeList=StringLiteral) (DOT replTablesExcludeList=StringLiteral)?) - -> ^(TOK_REPL_TABLES $replTablesIncludeList $replTablesExcludeList?) - ; - -replStatusStatement -@init { pushMsg("replication status statement", state); } -@after { popMsg(state); } - : KW_REPL KW_STATUS - (dbName=identifier) - (KW_WITH replConf=replConfigs)? - -> ^(TOK_REPL_STATUS $dbName $replConf?) - ; - ddlStatement @init { pushMsg("ddl statement", state); } @after { popMsg(state); } diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/ReplClauseParser.g b/parser/src/java/org/apache/hadoop/hive/ql/parse/ReplClauseParser.g new file mode 100644 index 00000000000..0bcb1e556a9 --- /dev/null +++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/ReplClauseParser.g @@ -0,0 +1,110 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +parser grammar ReplClauseParser; + +options +{ +output=AST; +ASTLabelType=ASTNode; +backtrack=false; +k=3; +} + +@members { + @Override + public Object recoverFromMismatchedSet(IntStream input, + RecognitionException re, BitSet follow) throws RecognitionException { + throw re; + } + @Override + public void displayRecognitionError(String[] tokenNames, + RecognitionException e) { + gParent.errors.add(new ParseError(gParent, e, tokenNames)); + } +} + +@rulecatch { +catch (RecognitionException e) { + throw e; +} +} + +replicationClause +@init { gParent.pushMsg("replication clause", state); } +@after { gParent.popMsg(state); } + : KW_FOR (isMetadataOnly=KW_METADATA)? KW_REPLICATION LPAREN (replId=StringLiteral) RPAREN + -> ^(TOK_REPLICATION $replId $isMetadataOnly?) + ; + +replDumpStatement +@init { gParent.pushMsg("Replication dump statement", state); } +@after { gParent.popMsg(state); } + : KW_REPL KW_DUMP + (dbPolicy=replDbPolicy) + (KW_REPLACE oldDbPolicy=replDbPolicy)? + (KW_WITH replConf=replConfigs)? + -> ^(TOK_REPL_DUMP $dbPolicy ^(TOK_REPLACE $oldDbPolicy)? $replConf?) + ; + +replDbPolicy +@init { gParent.pushMsg("Repl dump DB replication policy", state); } +@after { gParent.popMsg(state); } + : + (dbName=identifier) (DOT tablePolicy=replTableLevelPolicy)? -> $dbName $tablePolicy? + ; + +replLoadStatement +@init { gParent.pushMsg("Replication load statement", state); } +@after { gParent.popMsg(state); } + : KW_REPL KW_LOAD + (sourceDbPolicy=replDbPolicy) + (KW_INTO dbName=identifier)? + (KW_WITH replConf=replConfigs)? + -> ^(TOK_REPL_LOAD $sourceDbPolicy ^(TOK_DBNAME $dbName)? $replConf?) + ; + +replConfigs +@init { gParent.pushMsg("Repl configurations", state); } +@after { gParent.popMsg(state); } + : + LPAREN replConfigsList RPAREN -> ^(TOK_REPL_CONFIG replConfigsList) + ; + +replConfigsList +@init { gParent.pushMsg("Repl configurations list", state); } +@after { gParent.popMsg(state); } + : + keyValueProperty (COMMA keyValueProperty)* -> ^(TOK_REPL_CONFIG_LIST keyValueProperty+) + ; + +replTableLevelPolicy +@init { gParent.pushMsg("Replication table level policy definition", state); } +@after { gParent.popMsg(state); } + : + ((replTablesIncludeList=StringLiteral) (DOT replTablesExcludeList=StringLiteral)?) + -> ^(TOK_REPL_TABLES $replTablesIncludeList $replTablesExcludeList?) + ; + +replStatusStatement +@init { gParent.pushMsg("replication status statement", state); } +@after { gParent.popMsg(state); } + : KW_REPL KW_STATUS + (dbName=identifier) + (KW_WITH replConf=replConfigs)? + -> ^(TOK_REPL_STATUS $dbName $replConf?) + ; +