ramitg254 commented on code in PR #6413:
URL: https://github.com/apache/hive/pull/6413#discussion_r3491013104
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/SplitUpdateRewriter.java:
##########
@@ -134,4 +112,45 @@ public ParseUtils.ReparseResult rewrite(Context context,
UpdateStatement updateB
return rr;
}
+
+ protected void appendPartitionColumns(UpdateStatement updateBlock,
MultiInsertSqlGenerator sqlGenerator,
+ List<String> insertValues, Map<Integer, ASTNode> setColExprs,
List<FieldSchema> nonPartCols,
+ int columnOffset, boolean prependComma) {
+ for (FieldSchema partCol : updateBlock.getTargetTable().getPartCols()) {
+ String identifier = HiveUtils.unparseIdentifier(partCol.getName(), conf);
+
insertValues.set(updateBlock.getTargetTable().getColumnIndexByName(partCol.getName()),
+ sqlGenerator.qualify(identifier));
+ }
+ }
+
+ protected void appendUpdateColumn(UpdateStatement updateBlock,
+ MultiInsertSqlGenerator sqlGenerator, List<String> insertValues,
+ Map<Integer, ASTNode> setColExprs, String columnName, int
setColExprIndex, int columnOffset,
+ boolean prependComma) {
+ String identifier = HiveUtils.unparseIdentifier(columnName, conf);
+
+ // The insert value is placed for every column (data and partition).
+ int index = updateBlock.getTargetTable().getColumnIndexByName(columnName);
+ insertValues.set(index, sqlGenerator.qualify(identifier));
+
+ if (prependComma) {
+ sqlGenerator.append(",");
+ }
Review Comment:
This is not true as when all columns of the table are partition columns in
that non part cols will be empty and we need first boolean check in case of
partition columns in case of that as well:
so applied the patch as you suggested but included a check for this case in
PartitionSplitUpdateRewriter.java like:
```
boolean first = partCols.size() ==
updateBlock.getTargetTable().getAllCols().size();
for (int i = 0; i < partCols.size(); i++) {
if (first) {
first = false;
} else {
sqlGenerator.append(",");
}
appendUpdateColumn(updateBlock, sqlGenerator, insertValues,
setColExprs,
partCols.get(i).getName(),
updateBlock.getTargetTable().getCols().size() + i + columnOffset);
}
```
--
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]