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

luoyuxia commented on FLINK-26542:
----------------------------------

To fix it, we need to generate unique column alias for such case.

> Fix the issue that  schema of both sides of union won't match when one side 
> of union select fields with same names
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-26542
>                 URL: https://issues.apache.org/jira/browse/FLINK-26542
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Connectors / Hive
>            Reporter: luoyuxia
>            Priority: Major
>             Fix For: 1.16.0
>
>
> With Hive dialect, for union SQL statement, when one side of union selects 
> multiple fields with same name, the fields will be overwritten and then only 
> retain one field. Then, it will throw the exception " Schema of both sides of 
> union should match".
> The exception can be reproduced using following code:
> {code:java}
> tableEnv.executeSql("create table src(key string, value string)");
> tableEnv.executeSql("create table src2(key string, value string)");
> List<Row> results =
>                 queryResult(
>                         tableEnv.sqlQuery(
>                                 "select key, value from src union all select 
> key, key from src2"));
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to