public abstract class TableEnvironment extends Object
Constructor and Description |
---|
TableEnvironment(TableConfig config) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkValidTableName(String name)
Checks if the chosen table name is valid.
|
TableConfig |
config() |
String |
createUniqueAttributeName()
Returns a unique temporary attribute name.
|
TableConfig |
getConfig()
Returns the table config to define the runtime behavior of the Table API.
|
protected <A> scala.Tuple2<String[],int[]> |
getFieldInfo(TypeInformation<A> inputType)
Returns field names and field positions for a given
TypeInformation . |
protected <A> scala.Tuple2<String[],int[]> |
getFieldInfo(TypeInformation<A> inputType,
Expression[] exprs)
Returns field names and field positions for a given
TypeInformation and Array of
Expression . |
org.apache.calcite.tools.FrameworkConfig |
getFrameworkConfig()
Returns the Calcite
FrameworkConfig of this TableEnvironment. |
FunctionCatalog |
getFunctionCatalog() |
org.apache.calcite.plan.RelOptPlanner |
getPlanner()
Returns the Calcite
RelOptPlanner of this TableEnvironment. |
FlinkRelBuilder |
getRelBuilder()
Returns the
FlinkRelBuilder of this TableEnvironment. |
protected org.apache.calcite.rel.type.RelDataType |
getRowType(String name) |
static BatchTableEnvironment |
getTableEnvironment(ExecutionEnvironment executionEnvironment)
Returns a
JavaBatchTableEnv for a Java JavaBatchExecEnv . |
static BatchTableEnvironment |
getTableEnvironment(ExecutionEnvironment executionEnvironment)
Returns a
ScalaBatchTableEnv for a Scala ScalaBatchExecEnv . |
static BatchTableEnvironment |
getTableEnvironment(ExecutionEnvironment executionEnvironment,
TableConfig tableConfig)
|
static BatchTableEnvironment |
getTableEnvironment(ExecutionEnvironment executionEnvironment,
TableConfig tableConfig)
|
static StreamTableEnvironment |
getTableEnvironment(StreamExecutionEnvironment executionEnvironment)
Returns a
JavaStreamTableEnv for a Java JavaStreamExecEnv . |
static StreamTableEnvironment |
getTableEnvironment(StreamExecutionEnvironment executionEnvironment)
Returns a
ScalaStreamTableEnv for a Scala stream ScalaStreamExecEnv . |
static StreamTableEnvironment |
getTableEnvironment(StreamExecutionEnvironment executionEnvironment,
TableConfig tableConfig)
|
static StreamTableEnvironment |
getTableEnvironment(StreamExecutionEnvironment executionEnvironment,
TableConfig tableConfig)
Returns a
ScalaStreamTableEnv for a Scala stream ScalaStreamExecEnv . |
FlinkTypeFactory |
getTypeFactory()
Returns the
FlinkTypeFactory of this TableEnvironment. |
protected boolean |
isRegistered(String name)
Checks if a table is registered under the given name.
|
void |
registerTable(String name,
Table table)
Registers a
Table under a unique name in the TableEnvironment's catalog. |
protected void |
registerTableInternal(String name,
org.apache.calcite.schema.impl.AbstractTable table)
Registers a Calcite
AbstractTable in the TableEnvironment's catalog. |
protected FlinkRelBuilder |
relBuilder() |
protected void |
replaceRegisteredTable(String name,
org.apache.calcite.schema.impl.AbstractTable table)
Replaces a registered Table with another Table under the same name.
|
abstract Table |
sql(String query)
Evaluates a SQL query on registered tables and retrieves the result as a
Table . |
abstract <T> void |
writeToSink(Table table,
TableSink<T> sink)
Writes a
Table to a TableSink . |
public TableEnvironment(TableConfig config)
public static BatchTableEnvironment getTableEnvironment(ExecutionEnvironment executionEnvironment)
JavaBatchTableEnv
for a Java JavaBatchExecEnv
.
executionEnvironment
- The Java batch ExecutionEnvironment.public static BatchTableEnvironment getTableEnvironment(ExecutionEnvironment executionEnvironment, TableConfig tableConfig)
executionEnvironment
- The Java batch ExecutionEnvironment.tableConfig
- The TableConfig for the new TableEnvironment.public static BatchTableEnvironment getTableEnvironment(ExecutionEnvironment executionEnvironment)
ScalaBatchTableEnv
for a Scala ScalaBatchExecEnv
.
executionEnvironment
- The Scala batch ExecutionEnvironment.public static BatchTableEnvironment getTableEnvironment(ExecutionEnvironment executionEnvironment, TableConfig tableConfig)
executionEnvironment
- The Scala batch ExecutionEnvironment.tableConfig
- The TableConfig for the new TableEnvironment.public static StreamTableEnvironment getTableEnvironment(StreamExecutionEnvironment executionEnvironment)
JavaStreamTableEnv
for a Java JavaStreamExecEnv
.
executionEnvironment
- The Java StreamExecutionEnvironment.public static StreamTableEnvironment getTableEnvironment(StreamExecutionEnvironment executionEnvironment, TableConfig tableConfig)
executionEnvironment
- The Java StreamExecutionEnvironment.tableConfig
- The TableConfig for the new TableEnvironment.public static StreamTableEnvironment getTableEnvironment(StreamExecutionEnvironment executionEnvironment)
ScalaStreamTableEnv
for a Scala stream ScalaStreamExecEnv
.
executionEnvironment
- The Scala StreamExecutionEnvironment.public static StreamTableEnvironment getTableEnvironment(StreamExecutionEnvironment executionEnvironment, TableConfig tableConfig)
ScalaStreamTableEnv
for a Scala stream ScalaStreamExecEnv
.
executionEnvironment
- The Scala StreamExecutionEnvironment.tableConfig
- The TableConfig for the new TableEnvironment.public TableConfig config()
protected FlinkRelBuilder relBuilder()
public TableConfig getConfig()
public void registerTable(String name, Table table)
Table
under a unique name in the TableEnvironment's catalog.
Registered tables can be referenced in SQL queries.
name
- The name under which the table is registered.table
- The table to register.protected void replaceRegisteredTable(String name, org.apache.calcite.schema.impl.AbstractTable table)
DataStreamTable
with a TranslatableTable
.
name
- Name of the table to replace.table
- The table that replaces the previous table.public abstract Table sql(String query)
Table
.
All tables referenced by the query must be registered in the TableEnvironment.
query
- The SQL query to evaluate.public abstract <T> void writeToSink(Table table, TableSink<T> sink)
Table
to a TableSink
.
protected void registerTableInternal(String name, org.apache.calcite.schema.impl.AbstractTable table)
AbstractTable
in the TableEnvironment's catalog.
name
- The name under which the table is registered.table
- The table to register in the catalogValidationException
- if another table is registered under the provided name.protected abstract void checkValidTableName(String name)
name
- The table name to check.protected boolean isRegistered(String name)
name
- The table name to check.protected org.apache.calcite.rel.type.RelDataType getRowType(String name)
public String createUniqueAttributeName()
public FlinkRelBuilder getRelBuilder()
FlinkRelBuilder
of this TableEnvironment.public org.apache.calcite.plan.RelOptPlanner getPlanner()
RelOptPlanner
of this TableEnvironment.public FlinkTypeFactory getTypeFactory()
FlinkTypeFactory
of this TableEnvironment.public FunctionCatalog getFunctionCatalog()
public org.apache.calcite.tools.FrameworkConfig getFrameworkConfig()
FrameworkConfig
of this TableEnvironment.protected <A> scala.Tuple2<String[],int[]> getFieldInfo(TypeInformation<A> inputType)
TypeInformation
.
Field names are automatically extracted for
CompositeType
.
The method fails if inputType is not a
CompositeType
.
inputType
- The TypeInformation extract the field names and positions from.protected <A> scala.Tuple2<String[],int[]> getFieldInfo(TypeInformation<A> inputType, Expression[] exprs)
TypeInformation
and Array
of
Expression
.
inputType
- The TypeInformation
against which the Expression
s are evaluated.exprs
- The expressions that define the field names.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.