LakeShen commented on code in PR #3393:
URL: https://github.com/apache/calcite/pull/3393#discussion_r1341464477
##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -4769,19 +4778,51 @@ private void convertValuesImpl(
return;
}
- for (SqlNode rowConstructor1 : values.getOperandList()) {
- SqlCall rowConstructor = (SqlCall) rowConstructor1;
+ SqlCall insertOp = callStack.peek();
+ 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);
+ }
+
+ for (SqlNode rowConstructor : values.getOperandList()) {
+ SqlCall rowConstructor0 = (SqlCall) rowConstructor;
Review Comment:
Hi @zstan ,for me, when I see a 0 or 1 in the code, I usually assume that
the 0 or 1 has a special meaning, it may represent the element index
information, or in some cases the first or second element.
If I were to suggest, I would suggest the second,but this is just my advice
and thoughts,It has no impact on this PR.
So It's ok for you to follow your ideas:)
--
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]