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
param: execEnv The ExecutionEnvironment
which is wrapped in this BatchTableEnvironment
.
param: config The TableConfig
of this BatchTableEnvironment
.
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 |
getBuiltInNormRuleSet()
Returns the built-in normalization rules that are defined by the environment.
|
protected org.apache.calcite.tools.RuleSet |
getBuiltInPhysicalOptRuleSet()
Returns the built-in optimization rules that are defined by the environment.
|
protected <IN,OUT> scala.Option<MapFunction<IN,OUT>> |
getConversionMapper(TypeInformation<IN> physicalTypeInfo,
RowSchema schema,
TypeInformation<OUT> requestedTypeInfo,
String functionName)
Creates a final converter that maps the internal row type to external type.
|
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,
TableSource<?> tableSource)
Registers an external
BatchTableSource in this TableEnvironment 's catalog. |
protected <A> DataSet<A> |
translate(org.apache.calcite.rel.RelNode logicalPlan,
org.apache.calcite.rel.type.RelDataType logicalType,
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,
QueryConfig queryConfig)
Writes a
Table to a TableSink . |
attrNameCntr, config, createUniqueAttributeName, DEFAULT_PROCTIME_ATTRIBUTE, DEFAULT_ROWTIME_ATTRIBUTE, functionCatalog, generateRowConverterFunction, getBuiltInLogicalOptRuleSet, getConfig, getFieldIndices, getFieldIndices, getFieldInfo, getFieldInfo, getFieldNames, getFieldNames, getFieldTypes, getFrameworkConfig, getFunctionCatalog, getLogicalOptRuleSet, getNormRuleSet, getPhysicalOptRuleSet, getPlanner, getRegisteredExternalCatalog, getRelBuilder, getRowType, getSqlOperatorTable, getSqlParserConfig, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTypeFactory, isRegistered, registerAggregateFunctionInternal, registerExternalCatalog, registerFunction, registerTable, registerTableFunctionInternal, registerTableInternal, relBuilder, replaceRegisteredTable, runHepPlanner, runVolcanoPlanner, scan, scan, sql, 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 void registerTableSource(String name, TableSource<?> tableSource)
BatchTableSource
in this TableEnvironment
's catalog.
Registered tables can be referenced in SQL queries.
registerTableSource
in class TableEnvironment
name
- The name under which the TableSource
is registered.tableSource
- The TableSource
to register.public <T> void writeToSink(Table table, TableSink<T> sink, QueryConfig queryConfig)
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.queryConfig
- The configuration for the query to generate.protected <IN,OUT> scala.Option<MapFunction<IN,OUT>> getConversionMapper(TypeInformation<IN> physicalTypeInfo, RowSchema schema, TypeInformation<OUT> requestedTypeInfo, String functionName)
physicalTypeInfo
- the input of the sinkschema
- the input schema with correct field names (esp. for POJO field mapping)requestedTypeInfo
- the output type of the sinkfunctionName
- name of the map function. Must not be unique but has to be a
valid Java class identifier.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 getBuiltInNormRuleSet()
getBuiltInNormRuleSet
in class TableEnvironment
protected org.apache.calcite.tools.RuleSet getBuiltInPhysicalOptRuleSet()
getBuiltInPhysicalOptRuleSet
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, org.apache.calcite.rel.type.RelDataType logicalType, TypeInformation<A> tpe)
RelNode
into a DataSet
. Converts to target type if necessary.
logicalPlan
- The root node of the relational expression tree.logicalType
- The row type of the result. Since the logicalPlan can lose the
field naming during optimization we pass the row type separately.tpe
- The TypeInformation
of the resulting DataSet
.DataSet
that corresponds to the translated Table
.Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.