[
https://issues.apache.org/jira/browse/CALCITE-5214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Zhen Chen resolved CALCITE-5214.
--------------------------------
Resolution: Fixed
According to the PR description, it can now execute properly on the main
branch, and I have verified that it works based on the case outlined in the
Jira ticket. I am marking it as resolved.
> Implicit type conversion fails in union sql
> -------------------------------------------
>
> Key: CALCITE-5214
> URL: https://issues.apache.org/jira/browse/CALCITE-5214
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.30.0
> Reporter: Hailin Wang
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
>
> The following test:
> {code:java}
> //
> org.apache.calcite.test.SqlToRelConverterTest#testUnionNullableImplicitTypeCoercion
> @Test void testUnionNullableImplicitTypeCoercion() {
> final String sql =
> "select id from (values(1), (null)) t (id) union select 'varchar-id' as
> id";
> sql(sql).ok();
> } {code}
> Fails with the following exception:
> {code:java}
> Exception in thread "main" java.lang.AssertionError: Conversion to relational
> algebra failed to preserve datatypes:
> validated type:
> RecordType(VARCHAR NOT NULL ID) NOT NULL
> converted type:
> RecordType(VARCHAR EXPR$0) NOT NULL
> rel:
> LogicalUnion(all=[false])
> LogicalProject(EXPR$0=[CAST($0):VARCHAR])
> LogicalValues(tuples=[[{ 1 }, { null }]])
> LogicalValues(tuples=[[{ 'varchar-id' }]]) at
> org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType(SqlToRelConverter.java:486)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:601)
> at org.apache.calcite.prepare.PlannerImpl.rel(PlannerImpl.java:259) {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)