kasakrisz commented on code in PR #2855:
URL: https://github.com/apache/hive/pull/2855#discussion_r887933328
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java:
##########
@@ -48,28 +52,43 @@ public class UpdateDeleteSemanticAnalyzer extends
RewriteSemanticAnalyzer {
super(queryState);
}
- protected void analyze(ASTNode tree) throws SemanticException {
+ @Override
+ protected ASTNode getTargetTableNode(ASTNode tree) {
+ // The first child should be the table we are updating / deleting from
+ ASTNode tabName = (ASTNode)tree.getChild(0);
+ assert tabName.getToken().getType() == HiveParser.TOK_TABNAME :
+ "Expected tablename as first child of " + operation + " but found
" + tabName.getName();
+ return tabName;
+ }
+
+ protected void analyze(ASTNode tree, Table table, ASTNode tabNameNode)
throws SemanticException {
Review Comment:
We need the quoted version of the db and table name. `TableName` object
can't generate it when identifier contains `'` character because it does not
escape the id but surround it with backticks.
```
public String getEscapedNotEmptyDbTable() {
return
db == null || db.trim().isEmpty() ?
"`" + table + "`" : "`" + db + "`" +
DatabaseName.CAT_DB_TABLE_SEPARATOR + "`" + table + "`";
}
```
Table object is good only in the update case. However the target table may
have an alias defined in merge statements and we need that alias for the
rewrite. It can be extracted from the `tabNameNode` AST.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]