Skip navigation links

Back to Flink Website

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

Table API (Java)
A BatchTableEnvironment can be used to create a Table from a DataSet.

See: Description

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

Table API (Java)
A BatchTableEnvironment can be used to create a Table from a DataSet. Equivalently, a StreamTableEnvironment can be used to create a Table from a DataStream.

Tables 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.getExecutionEnvironment();
 BatchTableEnvironment tEnv = TableEnvironment.getTableEnvironment(env);

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

 Table table = tEnv.fromDataSet(input);

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

 DataSet<WC> result = tEnv.toDataSet(filtered, WC.class);

 result.print();
 

As seen above, a Table can be converted back to the underlying API representation using BatchTableEnvironment.toDataSet(org.apache.flink.api.table.Table, java.lang.Class) or StreamTableEnvironment.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.