zstan commented on code in PR #3393:
URL: https://github.com/apache/calcite/pull/3393#discussion_r1342705678


##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -4769,19 +4778,53 @@ private void convertValuesImpl(
       return;
     }
 
-    for (SqlNode rowConstructor1 : values.getOperandList()) {
-      SqlCall rowConstructor = (SqlCall) rowConstructor1;
+    SqlCall insertOp = callStack.peek();
+    // resolve presence of default params
+    boolean processDefaults = (insertOp != null) && containsDefault(values);
+
+    if (targetRowType == null) {
+      RelDataType listType = validator().getValidatedNodeType(values);
+      targetRowType = SqlTypeUtil.promoteToRowType(typeFactory, listType, 
null);
+    }
+
+    assert insertOp instanceof SqlInsert || !processDefaults : "operation: " + 
insertOp;
+
+    @Nullable InitializerExpressionFactory initializerFactory = null;
+    @Nullable RelOptTable targetTable = null;
+    int[] mapping = null;
+
+    if (processDefaults) {
+      targetTable = getTargetTable(requireNonNull(insertOp, "insertOp"));
+      initializerFactory =
+          getInitializerFactory(getNamespace(requireNonNull(insertOp, 
"insertOp"))
+              .getTable());
+      mapping =
+          processColumnsMapping(requireNonNull(targetRowType, 
"targetRowType"), targetTable);
+    }

Review Comment:
   @JiajunBernoulli catch it, but try to simple comment lines you suggested 
(just to understand what variables are involved) and as i can see - the code 
will become harder to read. So i prefer to store as is.



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

Reply via email to