public class StreamTableEnvironment extends StreamTableEnvironment
TableEnvironment
for a Java StreamExecutionEnvironment
.
A TableEnvironment can be used to:
- convert a DataStream
to a Table
- register a DataStream
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 DataStream
- explain the AST and execution plan of a Table
Constructor and Description |
---|
StreamTableEnvironment(StreamExecutionEnvironment execEnv,
TableConfig config) |
Modifier and Type | Method and Description |
---|---|
<T> Table |
fromDataStream(DataStream<T> dataStream)
Converts the given
DataStream into a Table . |
<T> Table |
fromDataStream(DataStream<T> dataStream,
String fields)
Converts the given
DataStream into a Table with specified field names. |
<T> void |
registerDataStream(String name,
DataStream<T> dataStream)
Registers the given
DataStream as table in the
TableEnvironment 's catalog. |
<T> void |
registerDataStream(String name,
DataStream<T> dataStream,
String fields)
Registers the given
DataStream as table with specified field names in the
TableEnvironment 's catalog. |
<T> DataStream<T> |
toDataStream(Table table,
Class<T> clazz)
Converts the given
Table into a DataStream of a specified type. |
<T> DataStream<T> |
toDataStream(Table table,
TypeInformation<T> typeInfo)
Converts the given
Table into a DataStream of a specified type. |
checkValidTableName, createUniqueTableName, execEnv, ingest, registerDataStreamInternal, registerDataStreamInternal, registerTableSource, sql, translate, writeToSink
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 <T> Table fromDataStream(DataStream<T> dataStream)
DataStream
into a Table
.
The field names of the Table
are automatically derived from the type of the
DataStream
.
dataStream
- The DataStream
to be converted.Table
.public <T> Table fromDataStream(DataStream<T> dataStream, String fields)
DataStream
into a Table
with specified field names.
Example:
DataStream<Tuple2<String, Long>> stream = ...
Table tab = tableEnv.fromDataStream(stream, "a, b")
dataStream
- The DataStream
to be converted.fields
- The field names of the resulting Table
.Table
.public <T> void registerDataStream(String name, DataStream<T> dataStream)
DataStream
as table in the
TableEnvironment
's catalog.
Registered tables can be referenced in SQL queries.
The field names of the Table
are automatically derived
from the type of the DataStream
.
name
- The name under which the DataStream
is registered in the catalog.dataStream
- The DataStream
to register.public <T> void registerDataStream(String name, DataStream<T> dataStream, String fields)
DataStream
as table with specified field names in the
TableEnvironment
's catalog.
Registered tables can be referenced in SQL queries.
Example:
DataStream<Tuple2<String, Long>> set = ...
tableEnv.registerDataStream("myTable", set, "a, b")
name
- The name under which the DataStream
is registered in the catalog.dataStream
- The DataStream
to register.fields
- The field names of the registered table.public <T> DataStream<T> toDataStream(Table table, Class<T> clazz)
Table
into a DataStream
of a specified type.
The fields of the Table
are mapped to DataStream
fields as follows:
- Row
and Tuple
types: Fields are mapped by position, field types must match.
- POJO DataStream
types: Fields are mapped by field name, field types must match.
table
- The Table
to convert.clazz
- The class of the type of the resulting DataStream
.DataStream
.public <T> DataStream<T> toDataStream(Table table, TypeInformation<T> typeInfo)
Table
into a DataStream
of a specified type.
The fields of the Table
are mapped to DataStream
fields as follows:
- Row
and Tuple
types: Fields are mapped by position, field types must match.
- POJO DataStream
types: Fields are mapped by field name, field types must match.
table
- The Table
to convert.typeInfo
- The TypeInformation
that specifies the type of the DataStream
.DataStream
.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.