zstan commented on code in PR #2446:
URL: https://github.com/apache/ignite-3/pull/2446#discussion_r1295759987


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteSqlToRelConvertor.java:
##########
@@ -69,6 +83,98 @@ public IgniteSqlToRelConvertor(
         }
     }
 
+    @Override protected RelNode convertInsert(SqlInsert call) {
+        datasetStack.push(call);
+
+        RelNode rel = super.convertInsert(call);
+
+        datasetStack.pop();
+
+        return rel;
+    }
+
+    private static class DefaultChecker extends SqlShuttle {
+        @Override public @Nullable SqlNode visit(SqlCall call) {
+            if (call.getKind() == SqlKind.DEFAULT) {
+                throw new ControlFlowException();
+            }
+
+            return super.visit(call);
+        }
+    }
+
+    @Override public RelNode convertValues(SqlCall values, RelDataType 
targetRowType) {
+        boolean defaultValueFound = false;
+
+        DefaultChecker checker = new DefaultChecker();
+
+        try {
+            values.accept(checker);
+        } catch (ControlFlowException e) {
+            defaultValueFound = true;
+        }
+
+        if (defaultValueFound) {
+            SqlValidatorScope scope = validator.getOverScope(values);
+            assert scope != null;
+            Blackboard bb = createBlackboard(scope, null, false);
+
+            convertValuesImplEx(bb, values, targetRowType);
+            return bb.root();
+        } else {
+            // a bit lightweight than default processing one.
+            return super.convertValues(values, targetRowType);
+        }
+    }
+
+    private void convertValuesImplEx(Blackboard bb, SqlCall values, 
RelDataType targetRowType) {
+        SqlCall insertOp = datasetStack.peek();
+        assert insertOp instanceof SqlInsert;
+        assert values == ((SqlInsert) insertOp).getSource();
+        RelOptTable targetTable = getTargetTable(insertOp);
+        assert targetTable != null;
+
+        IgniteTable ignTable = targetTable.unwrap(IgniteTable.class);
+
+        List<RelDataTypeField> tblFields = 
targetTable.getRowType().getFieldList();
+        List<String> targetFields = targetRowType.getFieldNames();
+
+        for (SqlNode rowConstructor : values.getOperandList()) {
+            SqlCall rowConstructor0 = (SqlCall) rowConstructor;
+
+            List<Pair<RexNode, String>> exps = new 
ArrayList<>(targetFields.size());
+
+            int pos = 0;
+            int rowPos = 0;
+            for (RelDataTypeField fld : tblFields) {
+                if (fld.getName().equals(targetFields.get(rowPos))) {
+                    SqlNode operand = 
rowConstructor0.getOperandList().get(rowPos);
+
+                    if (operand.getKind() == SqlKind.DEFAULT) {

Review Comment:
   Such kind of query format is not possible )



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