Skip navigation links

Back to Flink Website

Package org.apache.flink.api.java.table

Table API (Java)
TableEnvironment can be used to create a Table from a DataSet or DataStream.

See: Description

Package org.apache.flink.api.java.table Description

Table API (Java)
TableEnvironment can be used to create a Table from a DataSet or DataStream.

This can be used to perform SQL-like queries on data. Please have a look at Table to see which operations are supported and how query strings are written.

Example:


 ExecutionEnvironment env = ExecutionEnvironment.createCollectionsEnvironment();

 DataSet<WC> input = env.fromElements(
   new WC("Hello", 1),
   new WC("Ciao", 1),
   new WC("Hello", 1));

 Table table = TableUtil.from(input);

 Table filtered = table
     .groupBy("word")
     .select("word.count as count, word")
     .filter("count = 2");

 DataSet<WC> result = TableUtil.toSet(filtered, WC.class);

 result.print();
 env.execute();
 

As seen above, a Table can be converted back to the underlying API representation using TableEnvironment.toDataSet(org.apache.flink.api.table.Table, java.lang.Class) or TableEnvironment.toDataStream(org.apache.flink.api.table.Table, java.lang.Class)}.

Skip navigation links

Back to Flink Website

Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.