You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Aleksey Plekhanov (Jira)" <ji...@apache.org> on 2021/08/03 13:59:00 UTC

[jira] [Comment Edited] (IGNITE-15123) Calcite. Multi-tuple insert fails on validation

    [ https://issues.apache.org/jira/browse/IGNITE-15123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17392322#comment-17392322 ] 

Aleksey Plekhanov edited comment on IGNITE-15123 at 8/3/21, 1:58 PM:
---------------------------------------------------------------------

[~korlov], I think it's not a correct fix for this problem. It's only a workaround for {{null}} values (which broke some other functionality), but the root cause is not fixed. It's correct for {{null}} value to be inferred to {{date}} type, the problem occurs when we try to find least restrictive type for all values and not take into account target data type. For example you can get the same error with the query:
{code:java}
INSERT INTO test VALUES ('2000-10-10'), (DATE '2000-10-10')
{code}
I propose to revert this patch and try to find another way how to fix the problem, since inferring {{null}} is broken now. For example {{AND}} function requires {{boolean}} types and infer {{null}} to {{boolean}}, but currently it doesn't work with {{nulls}}, since {{nulls}} converted to {{null}} data types. For example, expression like this: {{false and null}} should return {{false}}, but currently return {{null}}.  


was (Author: alex_pl):
[~korlov], I think it's not a correct fix for this problem. It's only a workaround for \{{null}} values (which broke some other functionality), but the root cause is not fixed. It's correct for {{null}} value to be inferred to {{date}} type, the problem occurs when we try to find least restrictive type for all values and not take into account target data type. For example you can get the same error with the query:

 
{code:java}
INSERT INTO test VALUES ('2000-10-10'), (DATE '2000-10-10')
{code}
 

I propose to revert this patch and try to find another way how to fix the problem, since inferring {{null}} is broken now. For example {{AND}} function requires {{boolean}} types and infer {{null}} to \{{boolean}}, but currently it doesn't work with {{nulls}}, since {{nulls}} converted to {{null}} data types. For example, expression like this: {{false and null}} should return {{false}}, but currently return {{null}}.  

> Calcite. Multi-tuple insert fails on validation
> -----------------------------------------------
>
>                 Key: IGNITE-15123
>                 URL: https://issues.apache.org/jira/browse/IGNITE-15123
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Konstantin Orlov
>            Assignee: Konstantin Orlov
>            Priority: Major
>              Labels: calcite, calcite3-required
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Currently a query like below fails on validation step:
> {code:java}
> create table test(d date);
> insert into test values('1990-01-01'),(null);
> {code}
> 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).
> {noformat}
> 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
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)