You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Josh Bradt (JIRA)" <ji...@apache.org> on 2019/05/31 15:26:00 UTC

[jira] [Created] (FLINK-12701) Column name alias causes exception when used with where and group-by

Josh Bradt created FLINK-12701:
----------------------------------

             Summary: 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


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)