public abstract class StreamTableEnvironment extends TableEnvironment
A TableEnvironment can be used to:
- convert DataStream
to a Table
- register a DataStream
as a table in the catalog
- register a Table
in the 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 DataStream
Constructor and Description |
---|
StreamTableEnvironment(StreamExecutionEnvironment 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.
|
StreamExecutionEnvironment |
execEnv() |
Table |
ingest(String tableName)
Ingests a registered table and returns the resulting
Table . |
protected <T> void |
registerDataStreamInternal(String name,
DataStream<T> dataStream,
boolean wrapper)
Registers a
DataStream as a table under a given name in the TableEnvironment 's
catalog. |
protected <T> void |
registerDataStreamInternal(String name,
DataStream<T> dataStream,
Expression[] fields,
boolean wrapper)
Registers a
DataStream as a table under a given name with field names as specified by
field expressions in the TableEnvironment 's catalog. |
void |
registerTableSource(String name,
StreamTableSource<?> tableSource)
Registers an external
StreamTableSource in this TableEnvironment 's catalog. |
Table |
sql(String query)
Evaluates a SQL query on registered tables and retrieves the result as a
Table . |
protected <A> DataStream<A> |
translate(Table table,
TypeInformation<A> tpe)
Translates a
Table into a DataStream . |
<T> void |
writeToSink(Table table,
TableSink<T> sink)
Writes a
Table to a TableSink . |
config, createUniqueAttributeName, getConfig, getFieldInfo, getFieldInfo, getFrameworkConfig, getFunctionCatalog, getPlanner, getRelBuilder, getRowType, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTableEnvironment, getTypeFactory, isRegistered, registerTable, registerTableInternal, relBuilder, replaceRegisteredTable
public StreamTableEnvironment(StreamExecutionEnvironment execEnv, TableConfig config)
public StreamExecutionEnvironment execEnv()
protected void checkValidTableName(String name)
checkValidTableName
in class TableEnvironment
name
- The table name to check.protected String createUniqueTableName()
public Table ingest(String tableName)
Table
.
The table to ingest must be registered in the TableEnvironment
's catalog.
tableName
- The name of the table to ingest.ValidationException
- if no table is registered under the given name.public void registerTableSource(String name, StreamTableSource<?> tableSource)
StreamTableSource
in this TableEnvironment
's catalog.
Registered tables can be referenced in SQL queries.
name
- The name under which the StreamTableSource
is registered.tableSource
- The StreamTableSource
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 DataStream
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.protected <T> void registerDataStreamInternal(String name, DataStream<T> dataStream, boolean wrapper)
DataStream
as a table under a given name in the TableEnvironment
's
catalog.
name
- The name under which the table is registered in the catalog.dataStream
- The DataStream
to register as table in the catalog.wrapper
- True if the registration has to wrap the datastreamTable
into a StreamableTable
protected <T> void registerDataStreamInternal(String name, DataStream<T> dataStream, Expression[] fields, boolean wrapper)
DataStream
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.dataStream
- The DataStream
to register as table in the catalog.fields
- The field expressions to define the field names of the table.wrapper
- True if the registration has to wrap the datastreamTable
into a StreamableTable
protected <A> DataStream<A> translate(Table table, TypeInformation<A> tpe)
Table
into a DataStream
.
The transformation involves optimizing the relational expression tree as defined by
Table API calls and / or SQL queries and generating corresponding DataStream
operators.
table
- The root node of the relational expression tree.tpe
- The TypeInformation
of the resulting DataStream
.DataStream
that corresponds to the translated Table
.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.