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

Maksim Zhuravkov edited comment on IGNITE-19307 at 5/27/24 1:26 PM:
--------------------------------------------------------------------

This issue is no longer reproducible (it was fixed in IGNITE-18831), since then 
set operations require columns to be of the same type families or NULL, and all 
these queries produce "Type mismatch in column 1 of UNION ALL" error.


was (Author: JIRAUSER298618):
This issue is no longer reproducible (it was fixed in IGNITE-18831), since then 
set operations require columns to be of the same type families or NULL.

> Sql. Set operations: Conversion to relational algebra failed to preserve 
> datatypes.
> -----------------------------------------------------------------------------------
>
>                 Key: IGNITE-19307
>                 URL: https://issues.apache.org/jira/browse/IGNITE-19307
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Minor
>              Labels: ignite-3
>             Fix For: 3.0.0-beta2
>
>
> The following query fails with "Conversion to relational algebra failed to 
> preserve datatypes"  
> {code:java}
> @Test
> public void test() {
>    sql("CREATE TABLE tt (id integer primary key, test_key integer)");
>    sql("INSERT INTO tt VALUES(1, 100)");
>    assertQuery("SELECT test_key FROM tt UNION ALL SELECT '1000'").check();
> }
> {code}
> Although the same expression with literal works as expected:
> {code:java}
> @Test
> public void test2() {
>    assertQuery("SELECT 100 UNION ALL SELECT '1000'").check();
> }
> {code}
> Error:
> {code:java}
> java.lang.AssertionError: Conversion to relational algebra failed to preserve 
> datatypes:
> validated type:
> RecordType(VARCHAR CHARACTER SET "UTF-8" NOT NULL TEST_KEY) NOT NULL
> converted type:
> RecordType(VARCHAR CHARACTER SET "UTF-8" EXPR$0) NOT NULL
> rel:
> LogicalUnion(all=[true])
>   LogicalProject(EXPR$0=[CAST($1):VARCHAR CHARACTER SET "UTF-8"])
>     IgniteLogicalTableScan(table=[[PUBLIC, TT]])
>   LogicalValues(tuples=[[{ _UTF-8'1000' }]])
> {code}
> When both side of set operation are columns query also works:
> {code:java}
> @Test
> public void test3() {
>     sql("CREATE TABLE tt (id integer primary key, test_key integer)");
>     sql("CREATE TABLE ttt (id integer primary key, test_key varchar)");
>     sql("INSERT INTO tt VALUES(1, 100)");
>     sql("INSERT INTO ttt VALUES(1, '200')");
>     assertQuery("SELECT test_key FROM tt UNION ALL SELECT test_key FROM 
> ttt").check();
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to