kasakrisz commented on code in PR #3430:
URL: https://github.com/apache/hive/pull/3430#discussion_r925153504


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/UpdateDeleteSemanticAnalyzer.java:
##########
@@ -285,30 +278,11 @@ private void analyzeSplitUpdate(ASTNode tree, Table 
mTable, ASTNode tabNameNode)
     rewrittenQueryStr.append("(SELECT ");
 
     boolean nonNativeAcid = AcidUtils.isNonNativeAcidTable(mTable);
-    int columnOffset;
-    List<String> deleteValues;
-    if (nonNativeAcid) {
-      List<FieldSchema> acidSelectColumns = 
mTable.getStorageHandler().acidSelectColumns(mTable, operation);
-      deleteValues = new ArrayList<>(acidSelectColumns.size());
-      for (FieldSchema fieldSchema : acidSelectColumns) {
-        String identifier = HiveUtils.unparseIdentifier(fieldSchema.getName(), 
this.conf);
-        rewrittenQueryStr.append(identifier).append(" AS ");
-        String prefixedIdentifier = HiveUtils.unparseIdentifier(DELETE_PREFIX 
+ fieldSchema.getName(), this.conf);
-        rewrittenQueryStr.append(prefixedIdentifier);
-        rewrittenQueryStr.append(",");
-        deleteValues.add(String.format("%s.%s", SUB_QUERY_ALIAS, 
prefixedIdentifier));
-      }
-
-      columnOffset = acidSelectColumns.size();
-    } else {
-      rewrittenQueryStr.append("ROW__ID,");
-      deleteValues = new ArrayList<>(1 + mTable.getPartCols().size());
-      deleteValues.add(SUB_QUERY_ALIAS + ".ROW__ID");
-      for (FieldSchema fieldSchema : mTable.getPartCols()) {
-        deleteValues.add(SUB_QUERY_ALIAS + "." + 
HiveUtils.unparseIdentifier(fieldSchema.getName(), conf));
-      }
-      columnOffset = 1;
-    }
+    ColumnAppender columnAppender = nonNativeAcid ? new 
NonNativeAcidColumnAppender(mTable, conf, SUB_QUERY_ALIAS) :
+            new NativeAcidColumnAppender(mTable, conf, SUB_QUERY_ALIAS);

Review Comment:
   I prefer keeping this in `RewriteSemanticAnalyzer` because these classes are 
used for generating query text when rewriting updates and merges.
   Added a factory method: 
   ```
   protected ColumnAppender getColumnAppender(String subQueryAlias)
   ```



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