deniskuzZ commented on code in PR #6685:
URL: https://github.com/apache/hive/pull/6685#discussion_r4468507779


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/MergeSemanticAnalyzer.java:
##########
@@ -131,7 +133,21 @@ WHEN NOT MATCHED THEN INSERT VALUES (source.a2, source.b2)
         .sourceName(sourceName)
         .sourceAlias(getSourceAlias(source, sourceName))
         .onClauseAsText(onClauseAsText);
-
+     
+    OnClauseAnalyzer oca = new OnClauseAnalyzer(onClause, targetTable, 
targetAlias,
+            conf, onClauseAsText);
+    oca.analyze();
+
+    boolean copyOnWriteMode = false;
+    HiveStorageHandler storageHandler = targetTable.getStorageHandler();
+    if (storageHandler != null) {
+      copyOnWriteMode = storageHandler.shouldOverwrite(targetTable, 
Context.Operation.MERGE);
+    }
+    // unresolved columns are not allowed in the on clause to avoid wrong 
results in Copy-On-Write mode
+    if (copyOnWriteMode && !oca.unresolvedColumns.isEmpty()) {

Review Comment:
   This rejects any unqualified column, not just ambiguous ones. E.g. ON tgt.id 
= src_only_col works today on both COW and MOR, but would fail after this 
change. Only unqualified columns that match a target column are a problem for 
COW. 
   Also, please reuse the existing ambiguous-column ErrorMsg instead of a 
free-form message, so COW and MOR report the same error.



-- 
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]

Reply via email to