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


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/CopyOnWriteMergeRewriter.java:
##########
@@ -149,8 +153,20 @@ public void 
appendWhenNotMatchedInsertClause(MergeStatement.InsertClause insertC
         hintStr = null;
       }
       List<String> values = 
sqlGenerator.getDeleteValues(Context.Operation.MERGE);
-      values.add(insertClause.getValuesClause());
       
+      if (insertClause.getColumnListText() != null) {
+        String[] columnNames = insertClause.getColumnListText()
+            .substring(1, insertClause.getColumnListText().length() - 
1).split(",");

Review Comment:
   Is this works when a column name has `,` ?
   ```
   merge into target_ice as t using source src ON t.a = src.a
   when not matched then insert (a, `c,c`) values (src.a, src.c);
   ```
   
   The original AST  of the merge statement already contains the column names 
in separate AST nodes:
   ```
   TOK_TABCOLNAME
      a
      c,c
   ```
   
https://github.com/apache/hive/blob/df45194268ffb10f9f7aae0ab4e3aec35a7b31d8/ql/src/java/org/apache/hadoop/hive/ql/parse/MergeSemanticAnalyzer.java#L343-L345
   
   and these are collected to a list
   
https://github.com/apache/hive/blob/df45194268ffb10f9f7aae0ab4e3aec35a7b31d8/ql/src/java/org/apache/hadoop/hive/ql/parse/MergeSemanticAnalyzer.java#L355
   
   Can you please try changing `MergeStatement.InsertClause.columnListText` 
from `String` to `List<String>`?



##########
ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/CopyOnWriteMergeRewriter.java:
##########
@@ -149,8 +153,20 @@ public void 
appendWhenNotMatchedInsertClause(MergeStatement.InsertClause insertC
         hintStr = null;
       }
       List<String> values = 
sqlGenerator.getDeleteValues(Context.Operation.MERGE);
-      values.add(insertClause.getValuesClause());
       
+      if (insertClause.getColumnListText() != null) {
+        String[] columnNames = insertClause.getColumnListText()
+            .substring(1, insertClause.getColumnListText().length() - 
1).split(",");
+        String[] columnValues = insertClause.getValuesClause().split(",");

Review Comment:
   Initially values are also represented in the AST
   ```
   TOK_FUNCTION
     struct
     .
       TOK_TABLE_OR_COL
         some_alias
       a
     .
       TOK_TABLE_OR_COL
         some_alias
       c,c
   ```
   We can try transform it to a `List<String>`
   



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