Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.37.0
-
None
-
None
Description
Reproducer (for SqlToRelConverterTest)
@Test void testUpdateSubQuery() { final String sql = "update emp\n" + "set empno = (\n" + " select cast(empno as BIGINT) from emp" + ")"; sql(sql).ok(); }
Produces the following assertion error
java.lang.AssertionError at org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion.needToCast(AbstractTypeCoercion.java:307) at org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion.needToCast(AbstractTypeCoercion.java:250) at org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion.coerceColumnType(AbstractTypeCoercion.java:210) at org.apache.calcite.sql.validate.implicit.TypeCoercionImpl.coerceSourceRowType(TypeCoercionImpl.java:676) at org.apache.calcite.sql.validate.implicit.TypeCoercionImpl.querySourceCoercion(TypeCoercionImpl.java:646) at org.apache.calcite.sql.validate.SqlValidatorImpl.checkTypeAssignment(SqlValidatorImpl.java:5313) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateUpdate(SqlValidatorImpl.java:5420) at org.apache.calcite.sql.SqlUpdate.validate(SqlUpdate.java:190) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1136) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:841) at org.apache.calcite.sql.test.AbstractSqlTester.convertSqlToRel2(AbstractSqlTester.java:543) at org.apache.calcite.sql.test.AbstractSqlTester.assertSqlConvertsTo(AbstractSqlTester.java:486) at org.apache.calcite.sql.test.AbstractSqlTester.assertConvertsTo(AbstractSqlTester.java:464) at org.apache.calcite.test.SqlToRelFixture.convertsTo(SqlToRelFixture.java:106) at org.apache.calcite.test.SqlToRelFixture.ok(SqlToRelFixture.java:94) at org.apache.calcite.test.SqlToRelConverterTest.testUpdateSubQuery(SqlToRelConverterTest.java:3077)
The same query without casting to BIGINT works fine.
Assertion line
// Should keep sync with rules in SqlTypeCoercionRule. assert SqlTypeUtil.canCastFrom(toType, fromType, mappingRule); return true;
When assertion fails, I see that
toType = INTEGER
fromType = RecordType(BIGINT EXPR$0)
Attachments
Attachments
Issue Links
- is related to
-
IGNITE-23183 Sql. Assertion error when validating an UPDATE query with a subquery expression
- Open
- links to