You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Wang Guanglei (Jira)" <ji...@apache.org> on 2021/09/07 03:09:00 UTC

[jira] [Created] (FLINK-24176) Column alias in Flink-SQL is unsuccessful after converting Table to DataStream

Wang Guanglei created FLINK-24176:
-------------------------------------

             Summary: Column alias in Flink-SQL is unsuccessful after converting Table to DataStream<Row>
                 Key: FLINK-24176
                 URL: https://issues.apache.org/jira/browse/FLINK-24176
             Project: Flink
          Issue Type: Bug
          Components: API / DataStream
    Affects Versions: 1.12.0
         Environment: java version "1.8.0_291"

Flink version : 1.12-csadh1.3.0.0

Flink scala version: 2.12
            Reporter: Wang Guanglei


Hi team,

    I found an interesting issue while using Flink-SQL. If the group window function and aggregating operation are used in one SQL statement at the same time, some column aliases will be unsuccessful after converting the table to DataStream<Row>. 

Following is a part of the code :
{code:java}
//代码占位符
tableEnv.createTemporaryView("my_table", in);
String sqlQuery = "SELECT c as alias_c, sum(a) as sum_a FROM my_table group by c, TUMBLE(ts, INTERVAL '1' SECOND)";
Table result = tableEnv.sqlQuery(sqlQuery);
System.out.println("Table schema: " + result.getSchema());
DataStream<Row> resultDataStream = tableEnv.toAppendStream(result, Row.class);
final RowTypeInfo type1 = (RowTypeInfo)resultDataStream.getType();
System.out.println("Field names: " + Arrays.toString(type1.getFieldNames()));
{code}
Output:

Table schema: root
 |-- *alias_c*: STRING
 |-- sum_a: INT

Field names: [*c*, sum_a]

 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)