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
param: execEnv The Java StreamExecutionEnvironment
of the TableEnvironment.
param: config The configuration of the TableEnvironment.
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,ACC> void |
registerFunction(String name,
AggregateFunction<T,ACC> f)
Registers an
AggregateFunction under a unique name in the TableEnvironment's catalog. |
<T> void |
registerFunction(String name,
TableFunction<T> tf)
Registers a
TableFunction under a unique name in the TableEnvironment's catalog. |
<T> DataStream<T> |
toAppendStream(Table table,
Class<T> clazz)
Converts the given
Table into an append DataStream of a specified type. |
<T> DataStream<T> |
toAppendStream(Table table,
Class<T> clazz,
StreamQueryConfig queryConfig)
Converts the given
Table into an append DataStream of a specified type. |
<T> DataStream<T> |
toAppendStream(Table table,
TypeInformation<T> typeInfo)
Converts the given
Table into an append DataStream of a specified type. |
<T> DataStream<T> |
toAppendStream(Table table,
TypeInformation<T> typeInfo,
StreamQueryConfig queryConfig)
Converts the given
Table into an append DataStream of a specified type. |
<T> DataStream<T> |
toDataStream(Table table,
Class<T> clazz)
Deprecated.
This method only supports conversion of append-only tables. In order to
make this more explicit in the future, please use toAppendStream() instead.
|
<T> DataStream<T> |
toDataStream(Table table,
Class<T> clazz,
StreamQueryConfig queryConfig)
Deprecated.
This method only supports conversion of append-only tables. In order to
make this more explicit in the future, please use toAppendStream() instead.
|
<T> DataStream<T> |
toDataStream(Table table,
TypeInformation<T> typeInfo)
Deprecated.
This method only supports conversion of append-only tables. In order to
make this more explicit in the future, please use toAppendStream() instead.
|
<T> DataStream<T> |
toDataStream(Table table,
TypeInformation<T> typeInfo,
StreamQueryConfig queryConfig)
Deprecated.
This method only supports conversion of append-only tables. In order to
make this more explicit in the future, please use toAppendStream() instead.
|
<T> DataStream<Tuple2<Boolean,T>> |
toRetractStream(Table table,
Class<T> clazz)
Converts the given
Table into a DataStream of add and retract messages. |
<T> DataStream<Tuple2<Boolean,T>> |
toRetractStream(Table table,
Class<T> clazz,
StreamQueryConfig queryConfig)
Converts the given
Table into a DataStream of add and retract messages. |
<T> DataStream<Tuple2<Boolean,T>> |
toRetractStream(Table table,
TypeInformation<T> typeInfo)
Converts the given
Table into a DataStream of add and retract messages. |
<T> DataStream<Tuple2<Boolean,T>> |
toRetractStream(Table table,
TypeInformation<T> typeInfo,
StreamQueryConfig queryConfig)
Converts the given
Table into a DataStream of add and retract messages. |
checkValidTableName, createUniqueTableName, execEnv, explain, getBuiltInDecoRuleSet, getBuiltInNormRuleSet, getBuiltInPhysicalOptRuleSet, getConversionMapper, getDecoRuleSet, getUniqueKeyFields, isAppendOnly, optimize, queryConfig, registerDataStreamInternal, registerDataStreamInternal, registerTableSource, translate, translate, translateToCRow, writeToSink
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 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 an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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.
NOTE: This method only supports conversion of append-only tables. In order to make this
more explicit in the future, please use toAppendStream()
instead.
If add and retract messages are required, use toRetractStream()
.
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 an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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.
NOTE: This method only supports conversion of append-only tables. In order to make this
more explicit in the future, please use toAppendStream()
instead.
If add and retract messages are required, use toRetractStream()
.
table
- The Table
to convert.typeInfo
- The TypeInformation
that specifies the type of the DataStream
.DataStream
.public <T> DataStream<T> toDataStream(Table table, Class<T> clazz, StreamQueryConfig queryConfig)
Table
into an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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.
NOTE: This method only supports conversion of append-only tables. In order to make this
more explicit in the future, please use toAppendStream()
instead.
If add and retract messages are required, use toRetractStream()
.
table
- The Table
to convert.clazz
- The class of the type of the resulting DataStream
.queryConfig
- The configuration of the query to generate.DataStream
.public <T> DataStream<T> toDataStream(Table table, TypeInformation<T> typeInfo, StreamQueryConfig queryConfig)
Table
into an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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.
NOTE: This method only supports conversion of append-only tables. In order to make this
more explicit in the future, please use toAppendStream()
instead.
If add and retract messages are required, use toRetractStream()
.
table
- The Table
to convert.typeInfo
- The TypeInformation
that specifies the type of the DataStream
.queryConfig
- The configuration of the query to generate.DataStream
.public <T> DataStream<T> toAppendStream(Table table, Class<T> clazz)
Table
into an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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> toAppendStream(Table table, TypeInformation<T> typeInfo)
Table
into an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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
.public <T> DataStream<T> toAppendStream(Table table, Class<T> clazz, StreamQueryConfig queryConfig)
Table
into an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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
.queryConfig
- The configuration of the query to generate.DataStream
.public <T> DataStream<T> toAppendStream(Table table, TypeInformation<T> typeInfo, StreamQueryConfig queryConfig)
Table
into an append DataStream
of a specified type.
The Table
must only have insert (append) changes. If the Table
is also modified
by update or delete changes, the conversion will fail.
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
.queryConfig
- The configuration of the query to generate.DataStream
.public <T> DataStream<Tuple2<Boolean,T>> toRetractStream(Table table, Class<T> clazz)
Table
into a DataStream
of add and retract messages.
The message will be encoded as JTuple2
. The first field is a JBool
flag,
the second field holds the record of the specified type T
.
A true JBool
flag indicates an add message, a false flag indicates a retract message.
The fields of the Table
are mapped to the requested type 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 requested record type.DataStream
.public <T> DataStream<Tuple2<Boolean,T>> toRetractStream(Table table, TypeInformation<T> typeInfo)
Table
into a DataStream
of add and retract messages.
The message will be encoded as JTuple2
. The first field is a JBool
flag,
the second field holds the record of the specified type T
.
A true JBool
flag indicates an add message, a false flag indicates a retract message.
The fields of the Table
are mapped to the requested type 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
of the requested record type.DataStream
.public <T> DataStream<Tuple2<Boolean,T>> toRetractStream(Table table, Class<T> clazz, StreamQueryConfig queryConfig)
Table
into a DataStream
of add and retract messages.
The message will be encoded as JTuple2
. The first field is a JBool
flag,
the second field holds the record of the specified type T
.
A true JBool
flag indicates an add message, a false flag indicates a retract message.
The fields of the Table
are mapped to the requested type 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 requested record type.queryConfig
- The configuration of the query to generate.DataStream
.public <T> DataStream<Tuple2<Boolean,T>> toRetractStream(Table table, TypeInformation<T> typeInfo, StreamQueryConfig queryConfig)
Table
into a DataStream
of add and retract messages.
The message will be encoded as JTuple2
. The first field is a JBool
flag,
the second field holds the record of the specified type T
.
A true JBool
flag indicates an add message, a false flag indicates a retract message.
The fields of the Table
are mapped to the requested type 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
of the requested record type.queryConfig
- The configuration of the query to generate.DataStream
.public <T> void registerFunction(String name, TableFunction<T> tf)
TableFunction
under a unique name in the TableEnvironment's catalog.
Registered functions can be referenced in Table API and SQL queries.
name
- The name under which the function is registered.tf
- The TableFunction to register.public <T,ACC> void registerFunction(String name, AggregateFunction<T,ACC> f)
AggregateFunction
under a unique name in the TableEnvironment's catalog.
Registered functions can be referenced in Table API and SQL queries.
name
- The name under which the function is registered.f
- The AggregateFunction to register.Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.