public abstract class BatchTableEnvironment extends TableEnvironment
A TableEnvironment can be used to:
- convert a DataSet
to a Table
- register a DataSet
in the TableEnvironment
's catalog
- register a Table
in the TableEnvironment
's catalog
- scan a registered table to obtain a Table
- specify a SQL query on registered tables to obtain a Table
- convert a Table
into a DataSet
- explain the AST and execution plan of a Table
Constructor and Description |
---|
BatchTableEnvironment(ExecutionEnvironment execEnv,
TableConfig config) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkValidTableName(String name)
Checks if the chosen table name is valid.
|
protected String |
createUniqueTableName()
Returns a unique table name according to the internal naming pattern.
|
ExecutionEnvironment |
execEnv() |
String |
explain(Table table)
Returns the AST of the specified Table API and SQL queries and the execution plan to compute
the result of the given
Table . |
String |
explain(Table table,
boolean extended)
Returns the AST of the specified Table API and SQL queries and the execution plan to compute
the result of the given
Table . |
protected org.apache.calcite.tools.RuleSet |
getBuiltInRuleSet()
Returns the built-in rules that are defined by the environment.
|
org.apache.calcite.rel.RelNode |
optimize(org.apache.calcite.rel.RelNode relNode)
Generates the optimized
RelNode tree from the original relational node tree. |
protected <T> void |
registerDataSetInternal(String name,
DataSet<T> dataSet)
Registers a
DataSet as a table under a given name in the TableEnvironment 's catalog. |
protected <T> void |
registerDataSetInternal(String name,
DataSet<T> dataSet,
Expression[] fields)
Registers a
DataSet as a table under a given name with field names as specified by
field expressions in the TableEnvironment 's catalog. |
void |
registerTableSource(String name,
BatchTableSource<?> tableSource)
Registers an external
BatchTableSource in this TableEnvironment 's catalog. |
Table |
scan(String tableName)
Scans a registered table and returns the resulting
Table . |
Table |
sql(String query)
Evaluates a SQL query on registered tables and retrieves the result as a
Table . |
protected <A> DataSet<A> |
translate(org.apache.calcite.rel.RelNode logicalPlan,
TypeInformation<A> tpe)
Translates a logical
RelNode into a DataSet . |
protected <A> DataSet<A> |
translate(Table table,
TypeInformation<A> tpe)
Translates a
Table into a DataSet . |
<T> void |
writeToSink(Table table,
TableSink<T> sink)
Writes a
Table to a TableSink . |
config, createUniqueAttributeName, getConfig, getFieldIndices, getFieldIndices, getFieldInfo, getFieldInfo, getFieldNames, getFieldNames, getFieldTypes, getFrameworkConfig, getFunctionCatalog, getPlanner, getRelBuilder, getRowType, getRuleSet, getSqlOperatorTable, getSqlParserConfig, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTypeFactory, isRegistered, registerFunction, registerTable, registerTableFunctionInternal, registerTableInternal, relBuilder, replaceRegisteredTable, validateType
public BatchTableEnvironment(ExecutionEnvironment execEnv, TableConfig config)
public ExecutionEnvironment execEnv()
protected void checkValidTableName(String name)
checkValidTableName
in class TableEnvironment
name
- The table name to check.protected String createUniqueTableName()
public Table scan(String tableName)
Table
.
The table to scan must be registered in the TableEnvironment
's catalog.
tableName
- The name of the table to scan.ValidationException
- if no table is registered under the given name.public void registerTableSource(String name, BatchTableSource<?> tableSource)
BatchTableSource
in this TableEnvironment
's catalog.
Registered tables can be referenced in SQL queries.
name
- The name under which the BatchTableSource
is registered.tableSource
- The BatchTableSource
to register.public Table sql(String query)
Table
.
All tables referenced by the query must be registered in the TableEnvironment.
sql
in class TableEnvironment
query
- The SQL query to evaluate.public <T> void writeToSink(Table table, TableSink<T> sink)
Table
to a TableSink
.
Internally, the Table
is translated into a DataSet
and handed over to the
TableSink
to write it.
writeToSink
in class TableEnvironment
table
- The Table
to write.sink
- The TableSink
to write the Table
to.public String explain(Table table, boolean extended)
Table
.
table
- The table for which the AST and execution plan will be returned.extended
- Flag to include detailed optimizer estimates.public String explain(Table table)
Table
.
table
- The table for which the AST and execution plan will be returned.protected <T> void registerDataSetInternal(String name, DataSet<T> dataSet)
DataSet
as a table under a given name in the TableEnvironment
's catalog.
name
- The name under which the table is registered in the catalog.dataSet
- The DataSet
to register as table in the catalog.protected <T> void registerDataSetInternal(String name, DataSet<T> dataSet, Expression[] fields)
DataSet
as a table under a given name with field names as specified by
field expressions in the TableEnvironment
's catalog.
name
- The name under which the table is registered in the catalog.dataSet
- The DataSet
to register as table in the catalog.fields
- The field expressions to define the field names of the table.protected org.apache.calcite.tools.RuleSet getBuiltInRuleSet()
getBuiltInRuleSet
in class TableEnvironment
public org.apache.calcite.rel.RelNode optimize(org.apache.calcite.rel.RelNode relNode)
RelNode
tree from the original relational node tree.
relNode
- The original RelNode
treeRelNode
treeprotected <A> DataSet<A> translate(Table table, TypeInformation<A> tpe)
Table
into a DataSet
.
The transformation involves optimizing the relational expression tree as defined by
Table API calls and / or SQL queries and generating corresponding DataSet
operators.
table
- The root node of the relational expression tree.tpe
- The TypeInformation
of the resulting DataSet
.DataSet
that corresponds to the translated Table
.protected <A> DataSet<A> translate(org.apache.calcite.rel.RelNode logicalPlan, TypeInformation<A> tpe)
RelNode
into a DataSet
.
logicalPlan
- The root node of the relational expression tree.tpe
- The TypeInformation
of the resulting DataSet
.DataSet
that corresponds to the translated Table
.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.