Spongebob created FLINK-26925: --------------------------------- Summary: loss scale in union situation Key: FLINK-26925 URL: https://issues.apache.org/jira/browse/FLINK-26925 Project: Flink Issue Type: Bug Components: Table SQL / API Reporter: Spongebob
when I union two columns that datatypes are decimal(38,4) and decimal(38,2), but got decimal(38,2) in return. This cause the problem that loss scale in result set. I think the final datatype should be decimal(38,4) would be fine. {code:java} TableEnvironment tableEnvironment = TableEnvironment.create(EnvironmentSettings.newInstance().inBatchMode().build()); Table t1 = tableEnvironment.sqlQuery("select cast(1.23 as decimal(38,2)) as a"); Table t2 = tableEnvironment.sqlQuery("select cast(4.5678 as decimal(38,4)) as a"); tableEnvironment.createTemporaryView("t1", t1); tableEnvironment.createTemporaryView("t2", t2); tableEnvironment.executeSql("select a from t1 union all select a from t2").print(); tableEnvironment.sqlQuery("select a from t1 union all select a from t2").printSchema(); // output +------------------------------------------+ | a | +------------------------------------------+ | 1.23 | | 4.57 | +------------------------------------------+ 2 rows in set ( `a` DECIMAL(38, 2) NOT NULL ){code} -- This message was sent by Atlassian Jira (v8.20.1#820001)