flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jark Wu (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-4240) Cannot use expressions in Scala Table API's groupBy method
Date Thu, 21 Jul 2016 14:51:20 GMT

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

Jark Wu commented on FLINK-4240:
--------------------------------

It's not a bug I think as we cannot select a column not in Group By. 

In this case we can rename the grouping field and it will work
{code}
    val tblResult = input1.groupBy('a % 4 as 'd).select('d);
{code}


> Cannot use expressions in Scala Table API's groupBy method
> ----------------------------------------------------------
>
>                 Key: FLINK-4240
>                 URL: https://issues.apache.org/jira/browse/FLINK-4240
>             Project: Flink
>          Issue Type: Bug
>          Components: Table API & SQL
>    Affects Versions: 1.1.0
>            Reporter: Till Rohrmann
>
> The following code fails even though it should be supported according to the documentation:
> {code}
> package com.dataartisans.batch
> import org.apache.flink.api.scala._
> import org.apache.flink.api.scala.table._
> import org.apache.flink.api.table.{Row, TableConfig, TableEnvironment}
> object ScalaSimpleTableAPIJob {
>   def main(args: Array[String]): Unit = {
>     val env = ExecutionEnvironment.getExecutionEnvironment
>     val tblConfig = new TableConfig
>     val tblEnv = TableEnvironment.getTableEnvironment(env, tblConfig)
>     val input1Seq = 0 until 10 map {x => (x, ('a' + x).toChar.toString, x.toDouble)}
>     val inputDS1 = env.fromCollection(input1Seq)
>     val input1 = tblEnv.fromDataSet(inputDS1, 'a, 'b, 'c)
>     // fails with org.apache.flink.api.table.ValidationException: cannot resolve [a]
given input [('a % 4)]
>     val tblResult = input1.groupBy('a % 4).select('a);
>     val result = tblEnv.toDataSet[Row](tblResult)
>     result.print()
>   }
> }
> {code}
> {code}
> Exception in thread "main" org.apache.flink.api.table.ValidationException: cannot resolve
[a] given input [('a % 4)]
> 	at org.apache.flink.api.table.plan.logical.LogicalNode.failValidation(LogicalNode.scala:143)
> 	at org.apache.flink.api.table.plan.logical.LogicalNode$$anonfun$validate$1.applyOrElse(LogicalNode.scala:87)
> 	at org.apache.flink.api.table.plan.logical.LogicalNode$$anonfun$validate$1.applyOrElse(LogicalNode.scala:84)
> 	at org.apache.flink.api.table.trees.TreeNode.postOrderTransform(TreeNode.scala:72)
> 	at org.apache.flink.api.table.plan.logical.LogicalNode.org$apache$flink$api$table$plan$logical$LogicalNode$$expressionPostOrderTransform$1(LogicalNode.scala:120)
> 	at org.apache.flink.api.table.plan.logical.LogicalNode$$anonfun$7$$anonfun$apply$1.apply(LogicalNode.scala:133)
> 	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
> 	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
> 	at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
> 	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
> 	at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
> 	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
> 	at org.apache.flink.api.table.plan.logical.LogicalNode$$anonfun$7.apply(LogicalNode.scala:132)
> 	at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
> 	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
> 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
> 	at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
> 	at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:103)
> 	at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:47)
> 	at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)
> 	at scala.collection.AbstractIterator.to(Iterator.scala:1157)
> 	at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:265)
> 	at scala.collection.AbstractIterator.toBuffer(Iterator.scala:1157)
> 	at scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:252)
> 	at scala.collection.AbstractIterator.toArray(Iterator.scala:1157)
> 	at org.apache.flink.api.table.plan.logical.LogicalNode.expressionPostOrderTransform(LogicalNode.scala:137)
> 	at org.apache.flink.api.table.plan.logical.LogicalNode.validate(LogicalNode.scala:84)
> 	at org.apache.flink.api.table.plan.logical.Project.validate(operators.scala:57)
> 	at org.apache.flink.api.table.GroupedTable.select(table.scala:631)
> 	at com.dataartisans.batch.ScalaSimpleTableAPIJob$.main(ScalaSimpleTableAPIJob.scala:26)
> 	at com.dataartisans.batch.ScalaSimpleTableAPIJob.main(ScalaSimpleTableAPIJob.scala)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:497)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message