kasakrisz commented on code in PR #5267:
URL: https://github.com/apache/hive/pull/5267#discussion_r1620072587
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/MergeSemanticAnalyzer.java:
##########
@@ -350,26 +352,51 @@ private MergeStatement.InsertClause handleInsert(ASTNode
whenNotMatchedClause, S
throw new SemanticException(String.format("Column schema must have the
same length as values (%d vs %d)",
columnListNode.getChildCount(), valuesNode.getChildCount() - 1));
}
- UnparseTranslator defaultValuesTranslator = new UnparseTranslator(conf);
- defaultValuesTranslator.enable();
- List<String> targetSchema = processTableColumnNames(columnListNode,
targetTable.getFullyQualifiedName());
- collectDefaultValues(valuesNode, targetTable, targetSchema,
defaultValuesTranslator);
- defaultValuesTranslator.applyTranslations(ctx.getTokenRewriteStream());
- String valuesClause = getMatchedText(valuesNode);
- valuesClause = valuesClause.substring(1, valuesClause.length() - 1);
//strip '(' and ')'
- String extraPredicate = getWhenClausePredicate(whenNotMatchedClause);
- return new MergeStatement.InsertClause(
- getMatchedText(columnListNode), valuesClause, onClausePredicate,
extraPredicate);
- }
+ List<String> columnNames;
+ if (columnListNode != null) {
+ columnNames = new ArrayList<>(valuesNode.getChildCount());
+ for (int i = 0; i < columnListNode.getChildCount(); ++i) {
+ ASTNode columnNameNode = (ASTNode) columnListNode.getChild(i);
+ String columnName =
ctx.getTokenRewriteStream().toString(columnNameNode.getTokenStartIndex(),
+ columnNameNode.getTokenStopIndex()).trim();
+ columnNames.add(columnName);
+ }
+ } else {
+ columnNames = null;
Review Comment:
When column names are specified additional steps must be done in both
Rewriter implementations so the null check is required. If the lack of column
names is represented by an empty list `List.isEmpty()` would be used.
--
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]