|
In Table and SQL Beta#Registering Tables#Register a Table, there is an error in Java API example:
// works for StreamExecutionEnvironment identically
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env);
// convert a DataSet into a Table
Table custT = tableEnv
.toTable(custDs, "name, zipcode")
.where("zipcode = '12345'")
.select("name");
// register the Table custT as table "custNames"
tableEnv.registerTable("custNames", custT);
When execute toTable() method, the first parameter should be tableEnv but not custDs as below code:
// works for StreamExecutionEnvironment identically
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env);
// convert a DataSet into a Table
Table custT = custDs
.toTable(tableEnv, "name, zipcode")
.where("zipcode = '12345'")
.select("name");
// register the Table custT as table "custNames"
tableEnv.registerTable("custNames", custT);
After modified, the error is also exist because the Java DataSet Object custDs could not convert to Scala DataSet implicitly in Java API.
So I think it is a bug when using Java API to execute toTable() method.
|