Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-15123

Calcite. Multi-tuple insert fails on validation

    XMLWordPrintableJSON

Details

    Description

      Currently a query like below fails on validation step:

      create table test(d date);
      insert into test values('1990-01-01'),(null);
      

      The reason is an extra validation step for insert with several tuples. This validation checks that all tuples have the same degree and the types of the corresponding fields throughout all tuples have the same family.

      In the example above types are mismatched cause type of the first tuple is CHAR, and type of the second tuple is DATE (because it's derived from table).

      class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to validate query.
      
      	at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareQuery(ExecutionServiceImpl.java:531)
      	at org.apache.ignite.internal.processors.query.calcite.prepare.QueryPlanCacheImpl.queryPlan(QueryPlanCacheImpl.java:84)
      	at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.executeQuery(ExecutionServiceImpl.java:391)
      	at org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.query(CalciteQueryProcessor.java:259)
      	at org.apache.ignite.internal.processors.query.calcite.integration.AbstractDdlIntegrationTest.executeSql(AbstractDdlIntegrationTest.java:77)
      	at org.apache.ignite.internal.processors.query.calcite.integration.TableDdlIntegrationTest.test(TableDdlIntegrationTest.java:91)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.apache.ignite.testframework.junits.GridAbstractTest$7.run(GridAbstractTest.java:2432)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.apache.calcite.tools.ValidationException: org.apache.calcite.runtime.CalciteContextException: From line 1, column 18 to line 1, column 44: Values passed to VALUES operator must have compatible types
      	at org.apache.ignite.internal.processors.query.calcite.prepare.IgnitePlanner.validate(IgnitePlanner.java:175)
      	at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareDml(ExecutionServiceImpl.java:601)
      	at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareSingle(ExecutionServiceImpl.java:565)
      	at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareQuery(ExecutionServiceImpl.java:514)
      	... 17 more
      Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 18 to line 1, column 44: Values passed to VALUES operator must have compatible types
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:506)
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:917)
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:902)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5271)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateValues(SqlValidatorImpl.java:5217)
      	at org.apache.calcite.sql.validate.TableConstructorNamespace.validateImpl(TableConstructorNamespace.java:61)
      	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:89)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1098)
      	at org.apache.ignite.internal.processors.query.calcite.prepare.IgniteSqlValidator.validateNamespace(IgniteSqlValidator.java:196)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1069)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateInsert(SqlValidatorImpl.java:4594)
      	at org.apache.ignite.internal.processors.query.calcite.prepare.IgniteSqlValidator.validateInsert(IgniteSqlValidator.java:115)
      	at org.apache.calcite.sql.SqlInsert.validate(SqlInsert.java:166)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1044)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:750)
      	at org.apache.ignite.internal.processors.query.calcite.prepare.IgnitePlanner.validate(IgnitePlanner.java:172)
      	... 20 more
      Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Values passed to VALUES operator must have compatible types
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:506)
      	at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:600)
      	... 35 more
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              korlov Konstantin Orlov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m