soumyakanti3578 commented on code in PR #5781:
URL: https://github.com/apache/hive/pull/5781#discussion_r2074368909


##########
ql/src/java/org/apache/hadoop/hive/ql/Context.java:
##########
@@ -361,8 +361,16 @@ private DestClausePrefix getMergeDestClausePrefix(ASTNode 
curNode) {
     assert insert != null && insert.getType() == HiveParser.TOK_INSERT;
     ASTNode query = (ASTNode) insert.getParent();
     assert query != null && query.getType() == HiveParser.TOK_QUERY;
-
-    int tokFromIdx = 
query.getFirstChildWithType(HiveParser.TOK_FROM).getChildIndex();
+    ASTNode from = (ASTNode) query.getFirstChildWithType(HiveParser.TOK_FROM);
+    
+    if (from == null) {
+      // We are here when TOK_FROM is missing from the AST.
+      // This can happen for merge queries with a predicate like 
`<joining_column> is null`
+      // in the matched clause.
+      return DestClausePrefix.MERGE;
+    }

Review Comment:
   I tested with other constants and the query fails for them. I added MERGE 
here because it seemed most logical, although I am unfamiliar with this too.
   
   I see that we track insert branch prefixes in `Map<Integer, 
DestClausePrefix> insertBranchToNamePrefix`. Here the key is the position of 
the INSERT node in the QUERY node's children - as mentioned 
[here](https://github.com/apache/hive/blob/8222107dffb3f37310e18e8af487bcd0e8107029/ql/src/java/org/apache/hadoop/hive/ql/Context.java#L384).
   
   So, I am wondering if I should first try to return the prefix from this map, 
and only defaulting to `MERGE` if a prefix is not found.



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to