flink tableapi inner join exception

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

flink tableapi inner join exception

刘 文
Exception in thread "main" org.apache.flink.table.api.ValidationException: join relations with ambiguous names: id, name, value
at org.apache.flink.table.plan.logical.LogicalNode.failValidation(LogicalNode.scala:156)
at org.apache.flink.table.plan.logical.Join.validate(operators.scala:463)
at org.apache.flink.table.api.Table.join(table.scala:589)
at org.apache.flink.table.api.Table.join(table.scala:397)
at com.opensourceteams.module.bigdata.flink.example.tableapi.operation.innerJoin.Run$.main(Run.scala:26)
at com.opensourceteams.module.bigdata.flink.example.tableapi.operation.innerJoin.Run.main(Run.scala)



————————————————————————————————————————————————————


package com.opensourceteams.module.bigdata.flink.example.tableapi.operation.innerJoin

import org.apache.flink.api.scala.{ExecutionEnvironment, _}
import org.apache.flink.table.api.TableEnvironment
import org.apache.flink.table.api.scala._

object Run {


def main(args: Array[String]): Unit = {

val env = ExecutionEnvironment.getExecutionEnvironment
val tableEnv = TableEnvironment.getTableEnvironment(env)

val dataSet = env.fromElements( (1,"a",10),(2,"b",20), (3,"c",30) )
val dataSet2 = env.fromElements( (1,"a",10),(20,"b",20), (30,"c",30) )



//从dataset转化为 table
val table = tableEnv.fromDataSet(dataSet,'id,'name,'value)
val table2 = tableEnv.fromDataSet(dataSet2,'id,'name,'value)



table.join(table2).where(" id = id ").first(1000).print()






}

}






Best,
thinktothings



Reply | Threaded
Open this post in threaded view
|

Re: flink tableapi inner join exception

Xingcan Cui
Hi,

As the message said, some columns share the same names. You could first rename the columns of one table with the `as` operation [1].

Best,
Xingcan

[1] https://ci.apache.org/projects/flink/flink-docs-master/dev/table/tableApi.html#scan-projection-and-filter 

On Mar 15, 2019, at 9:03 AM, 刘 文 <[hidden email]> wrote:

Exception in thread "main" org.apache.flink.table.api.ValidationException: join relations with ambiguous names: id, name, value
at org.apache.flink.table.plan.logical.LogicalNode.failValidation(LogicalNode.scala:156)
at org.apache.flink.table.plan.logical.Join.validate(operators.scala:463)
at org.apache.flink.table.api.Table.join(table.scala:589)
at org.apache.flink.table.api.Table.join(table.scala:397)
at com.opensourceteams.module.bigdata.flink.example.tableapi.operation.innerJoin.Run$.main(Run.scala:26)
at com.opensourceteams.module.bigdata.flink.example.tableapi.operation.innerJoin.Run.main(Run.scala)



————————————————————————————————————————————————————


package com.opensourceteams.module.bigdata.flink.example.tableapi.operation.innerJoin

import org.apache.flink.api.scala.{ExecutionEnvironment, _}
import org.apache.flink.table.api.TableEnvironment
import org.apache.flink.table.api.scala._

object Run {


def main(args: Array[String]): Unit = {

val env = ExecutionEnvironment.getExecutionEnvironment
val tableEnv = TableEnvironment.getTableEnvironment(env)

val dataSet = env.fromElements( (1,"a",10),(2,"b",20), (3,"c",30) )
val dataSet2 = env.fromElements( (1,"a",10),(20,"b",20), (30,"c",30) )



//从dataset转化为 table
val table = tableEnv.fromDataSet(dataSet,'id,'name,'value)
val table2 = tableEnv.fromDataSet(dataSet2,'id,'name,'value)



table.join(table2).where(" id = id ").first(1000).print()






}

}






Best,
thinktothings