Hi, Unfortunately at the moment, creating a row with named fields is not possible from the ROW constructor.
One solution could be to wrap it in a cast, like: CAST((f0 + 12, 'Hello world') AS ROW<i INT, s STRING>) Or you could create a UDF and use the @DataTypeHint to define the row return type, with named fields. Feel free to open an issue about that FG On Wed, Feb 2, 2022 at 5:18 PM Vladislav Keda < vladislav.k...@glowbyteconsulting.com> wrote: > Hi, > > I'm trying to create Row(..) using Flink SQL, but I can't assign names to > its fields. > > > *For example:*Input table1 structure:* (id INT, some_name STRING)* > Query: *select *, ROW(id, some_name) as row1 from table1* > Output result structure: > *(id INT , some_name STRING, row1 ROW (EXPR$0 INT, EXPR$1 STRING))* > > *Each nested field has a name like EXPR$<N> that does not satisfy me.* > > *If I write, for example:*Input table1 structure:* (id INT, some_name > STRING)* > Query: *select *, ROW(id as nested_id, some_name as nested_some_name) as > row1 from table1* > Output result structure: *(id INT , some_name STRING, row1 ROW (EXPR$0 > INT, EXPR$1 STRING))* > > > *I will get an exception like: * > > > > > > > > > *Caused by: org.apache.flink.table.api.SqlParserException: SQL parse > failed. Encountered "as" at line 1, column 20.Was expecting one of: ")" > ... "," ... at > org.apache.flink.table.planner.parse.CalciteParser.parse(CalciteParser.java:56) > at > org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:98) > at > org.apache.flink.table.api.internal.TableEnvironmentImpl.sqlQuery(TableEnvironmentImpl.java:704) > at > ru.glowbyte.streaming.core.operators.internal.sql.SqlDrivenOperator.sqlQuery(SqlDrivenOperator.java:159) > ... 59 more* > > How can I set the name for the field? > > Flink version - 1.13.3. > > --- > > Best Regards, > Vladislav Keda >