Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODP-1950 |HIVE-28226: Split Replication Commands from HiveParser.g. #48

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 1 addition & 66 deletions parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -956,13 +956,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); }
Expand All @@ -983,64 +976,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); }
Expand Down
110 changes: 110 additions & 0 deletions parser/src/java/org/apache/hadoop/hive/ql/parse/ReplClauseParser.g
Original file line number Diff line number Diff line change
@@ -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?)
;