问题描述
我在 Flink 1.4.0 上使用 Table API.我有一些 Table
对象要转换为 Row
类型的 DataSet
.该项目是使用 Maven 构建的,并在 IntelliJ 上导入.我有以下代码,IDE 无法解析方法 tableenv.toDataSet()
方法.请帮帮我.谢谢.
I am using the Table API on Flink 1.4.0. I have some Table
objects to be convert to a DataSet
of type Row
. The project was built using Maven and imported on IntelliJ. I have the following code and the IDE cannot resolve the method tableenv.toDataSet()
method. Please help me out. Thank you.
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
BatchTableEnvironment tableEnvironment = TableEnvironment.getTableEnvironment(env);
...
tableEnvironment.registerTableSource("table1",csvSource);
Table table1 = tableEnvironment.scan("table1");
DataSet<Row> result = tableEnvironment.toDataSet(table1, Row.class);
最后一条语句导致错误
无法解析 toDataSet() 方法"
推荐答案
您可能没有导入正确的 BatchTableEnvironment
.
You might not import the right BatchTableEnvironment
.
请检查您是否导入了 org.apache.flink.table.api.java.BatchTableEnvironment
而不是 org.apache.flink.table.api.BatchTableEnvironment
.前者是 Java 和 Scala 变体的公共基类.
Please check that you import org.apache.flink.table.api.java.BatchTableEnvironment
instead of org.apache.flink.table.api.BatchTableEnvironment
. The former is the common base class for the Java and Scala variants.
这篇关于Apache Flink:无法将 Table 对象转换为 DataSet 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!