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.
|
protected abstract org.apache.calcite.tools.RuleSet |
getBuiltInRuleSet()
Returns the built-in rules that are defined by the environment.
|
TableConfig |
getConfig()
Returns the table config to define the runtime behavior of the Table API.
|
static <A> int[] |
getFieldIndices(TableSource<A> tableSource)
Returns field indices for a given
TableSource . |
static int[] |
getFieldIndices(TypeInformation<?> inputType)
Returns field indexes for a given
TypeInformation . |
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 . |
static <A> String[] |
getFieldNames(TableSource<A> tableSource)
Returns field names for a given
TableSource . |
static <A> String[] |
getFieldNames(TypeInformation<A> inputType)
Returns field names for a given
TypeInformation . |
static TypeInformation<?>[] |
getFieldTypes(TypeInformation<?> inputType)
Returns field types for a given
TypeInformation . |
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) |
protected org.apache.calcite.tools.RuleSet |
getRuleSet()
Returns the rule set for this environment including a custom Calcite configuration.
|
protected org.apache.calcite.sql.SqlOperatorTable |
getSqlOperatorTable()
Returns the operator table for this environment including a custom Calcite configuration.
|
protected org.apache.calcite.sql.parser.SqlParser.Config |
getSqlParserConfig()
Returns the SQL parser config for this environment including a custom Calcite configuration.
|
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 |
registerFunction(String name,
ScalarFunction function)
Registers a
ScalarFunction under a unique name. |
void |
registerTable(String name,
Table table)
Registers a
Table under a unique name in the TableEnvironment's catalog. |
<T> void |
registerTableFunctionInternal(String name,
TableFunction<T> function,
TypeInformation<T> evidence$1)
Registers a
TableFunction under a unique name. |
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 . |
static void |
validateType(TypeInformation<?> typeInfo)
Validate if class represented by the typeInfo is static and globally accessible
|
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 static <A> String[] getFieldNames(TypeInformation<A> inputType)
TypeInformation
.
inputType
- The TypeInformation extract the field names.public static void validateType(TypeInformation<?> typeInfo)
typeInfo
- type to checkTableException
- if type does not meet these criteriapublic static int[] getFieldIndices(TypeInformation<?> inputType)
TypeInformation
.
inputType
- The TypeInformation extract the field positions from.public static TypeInformation<?>[] getFieldTypes(TypeInformation<?> inputType)
TypeInformation
.
inputType
- The TypeInformation to extract field types from.public static <A> String[] getFieldNames(TableSource<A> tableSource)
TableSource
.
tableSource
- The TableSource to extract field names from.public static <A> int[] getFieldIndices(TableSource<A> tableSource)
TableSource
.
tableSource
- The TableSource to extract field indices from.public TableConfig config()
protected FlinkRelBuilder relBuilder()
public TableConfig getConfig()
protected org.apache.calcite.sql.SqlOperatorTable getSqlOperatorTable()
protected org.apache.calcite.tools.RuleSet getRuleSet()
protected org.apache.calcite.sql.parser.SqlParser.Config getSqlParserConfig()
protected abstract org.apache.calcite.tools.RuleSet getBuiltInRuleSet()
public void registerFunction(String name, ScalarFunction function)
ScalarFunction
under a unique name. Replaces already existing
user-defined functions under this name.public <T> void registerTableFunctionInternal(String name, TableFunction<T> function, TypeInformation<T> evidence$1)
TableFunction
under a unique name. Replaces already existing
user-defined functions under this name.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 catalogTableException
- 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
.
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.