deniskuzZ commented on code in PR #6685:
URL: https://github.com/apache/hive/pull/6685#discussion_r4468418279
##########
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);
Review Comment:
+1 to @kasakrisz’s option 1.
The wrong result comes from the COW rewrite:
CopyOnWriteMergeRewriter.handleSource projects target columns with the t__
prefix, and replaceColumnRefsWithTargetPrefix rewrites only qualified tgt.
refs. So an unqualified a resolves to src.a, ON a = src.a becomes src.a =
src.a, and every target row matches. MOR doesn’t hit this because its join
exposes a on both sides, so RowResolver raises the ambiguity error.
**Could we move the guard into the COW path?**
OnClauseAnalyzer.handleUnresolvedColumns already identifies which
unqualified columns belong to the target. Pass those via MergeStatement and
fail only for them, e.g. with ErrorMsg.AMBIGUOUS_COLUMN. That gives the MOR
parity HIVE-29783 asks for, and oca.analyze() can stay scoped to the insert
branch as before, so ACID/MOR paths are untouched.
##########
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,
Review Comment:
Moving oca.analyze() out of the TOK_INSERT branch means it now runs for
every MERGE, including UPDATE/DELETE-only ones on ACID/MOR tables. Its > 2
table refs IllegalArgumentException can fire where it didn’t before. Please
keep it scoped to where it’s needed, or lazily evaluate it.
--
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]