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

Robert Metzger commented on FLINK-12701:
----------------------------------------

I also tried reproducing the issue with this query {code}SELECT Rides.rideId AS 
`test me` FROM Rides WHERE Rides.rideId > 20;{code}. (I suspected the AS `...` 
caused the issue)
Can you provide more details on how to reproduce this?

> Column name alias causes exception when used with where and group-by
> --------------------------------------------------------------------
>
>                 Key: FLINK-12701
>                 URL: https://issues.apache.org/jira/browse/FLINK-12701
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.8.0
>            Reporter: Josh Bradt
>            Priority: Major
>
> Assigning a column an alias containing a space sometimes causes an exception 
> even though the docs suggest this is valid.
> Assume we have a table {{Groups}} that contains a string-typed column called 
> {{name}}. Then the query
> {code:sql}
> SELECT `Groups`.`name` AS `Group Name` FROM `Groups`
> {code}
> works as expected, but
> {code:sql}
> SELECT `Groups`.`name` AS `Group Name` 
> FROM `Groups` 
> WHERE `Groups`.`name` LIKE 'Treat%' 
> ORDER BY `Groups`.`name` ASC
> {code}
> produces the following exception
> {code:java}
> org.apache.flink.api.common.typeutils.CompositeType$InvalidFieldReferenceException:
>  Invalid tuple field reference "Group Name".
>       at 
> org.apache.flink.api.java.typeutils.RowTypeInfo.getFlatFields(RowTypeInfo.java:97)
>       at 
> org.apache.flink.api.common.operators.Keys$ExpressionKeys.<init>(Keys.java:266)
>       at 
> org.apache.flink.api.common.operators.Keys$ExpressionKeys.<init>(Keys.java:223)
>       at org.apache.flink.api.java.DataSet.partitionByRange(DataSet.java:1298)
>       at 
> org.apache.flink.table.plan.nodes.dataset.DataSetSort.translateToPlan(DataSetSort.scala:99)
>       at 
> org.apache.flink.table.api.BatchTableEnvironment.translate(BatchTableEnvironment.scala:498)
>       at 
> org.apache.flink.table.api.BatchTableEnvironment.translate(BatchTableEnvironment.scala:476)
>       at 
> org.apache.flink.table.api.BatchTableEnvironment.writeToSink(BatchTableEnvironment.scala:311)
>       at 
> org.apache.flink.table.api.TableEnvironment.insertInto(TableEnvironment.scala:879)
>       at org.apache.flink.table.api.Table.insertInto(table.scala:1126)
>       [...]
> {code}
> If you remove the {{WHERE}} clause or the {{ORDER BY}} clause, it works fine. 
> It only fails when both are included. Additionally, it works fine if the 
> column alias ({{AS `Group Name`}}) is removed or if it doesn't contain a 
> space ({{AS `GroupName`}}).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to