0

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);

The last statement causes an error

"Cannot resolve toDataSet() method"

Fabian Hueske
  • 18,707
  • 2
  • 44
  • 49
Ranjan
  • 91
  • 8

2 Answers2

0

If you want to read a DataSet from a csv file, do it like following:

DataSet<YourType> csvInput = env.readCsvFile("hdfs:///the/CSV/file") ...

More on this: https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/batch/#data-sources

Alex
  • 839
  • 1
  • 12
  • 24
0

You might not import the right BatchTableEnvironment.

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.

Fabian Hueske
  • 18,707
  • 2
  • 44
  • 49