ramitg254 commented on code in PR #6413:
URL: https://github.com/apache/hive/pull/6413#discussion_r3388178245
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/SplitUpdateRewriter.java:
##########
@@ -134,4 +114,47 @@ public ParseUtils.ReparseResult rewrite(Context context,
UpdateStatement updateB
return rr;
}
+
+ private void appendUpdateColumn(UpdateStatement updateBlock,
+ MultiInsertSqlGenerator sqlGenerator, List<String> insertValues,
+ Map<Integer, ASTNode> setColExprs, String columnName, int
setColExprIndex, int columnOffset,
+ boolean appendToSelect, boolean prependComma) {
+ if (appendToSelect && prependComma) {
+ sqlGenerator.append(",");
+ }
+
+ Table targetTable = updateBlock.getTargetTable();
+ ASTNode setCol = updateBlock.getSetCols().get(columnName);
+ String identifier = HiveUtils.unparseIdentifier(columnName, conf);
+
+ if (appendToSelect) {
+ if (setCol != null) {
+ if (setCol.getType() == HiveParser.TOK_TABLE_OR_COL &&
+ setCol.getChildCount() == 1 && setCol.getChild(0).getType() ==
HiveParser.TOK_DEFAULT_VALUE) {
+
sqlGenerator.append(updateBlock.getColNameToDefaultConstraint().get(columnName));
+ } else {
+ sqlGenerator.append(identifier);
+ // This is one of the columns we're setting, record it's position so
we can come back
+ // later and patch it up. 0th is ROW_ID
+ setColExprs.put(setColExprIndex + columnOffset, setCol);
+ }
+ } else {
+ sqlGenerator.append(identifier);
+ }
+ sqlGenerator.append(" AS ");
+ sqlGenerator.append(identifier);
+ }
+
+ int index = targetTable.getColumnIndexByName(columnName);
+ ensureInsertValuesSize(insertValues, index);
+ insertValues.set(index, sqlGenerator.qualify(identifier));
+ }
+
+ private static void ensureInsertValuesSize(List<String> insertValues, int
index) {
Review Comment:
done
--
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]