@PublicEvolving public interface StreamStatementSet extends StatementSet
StatementSet
that integrates with the Java-specific DataStream
API.
It accepts pipelines defined by DML statements or Table
objects. The planner can
optimize all added statements together and then either submit them as one job or attach them to
the underlying StreamExecutionEnvironment
.
The added statements will be cleared when calling the StatementSet.execute()
or attachAsDataStream()
method.
Modifier and Type | Method and Description |
---|---|
StreamStatementSet |
addInsert(String targetPath,
Table table)
Adds a statement that the pipeline defined by the given
Table object should be
written to a table (backed by a DynamicTableSink ) that was registered under the
specified path. |
StreamStatementSet |
addInsert(String targetPath,
Table table,
boolean overwrite)
Adds a statement that the pipeline defined by the given
Table object should be
written to a table (backed by a DynamicTableSink ) that was registered under the
specified path. |
StreamStatementSet |
addInsert(TableDescriptor targetDescriptor,
Table table)
Adds a statement that the pipeline defined by the given
Table object should be
written to a table (backed by a DynamicTableSink ) expressed via the given TableDescriptor . |
StreamStatementSet |
addInsert(TableDescriptor targetDescriptor,
Table table,
boolean overwrite)
Adds a statement that the pipeline defined by the given
Table object should be
written to a table (backed by a DynamicTableSink ) expressed via the given TableDescriptor . |
StreamStatementSet |
addInsertSql(String statement)
Adds an
INSERT INTO SQL statement. |
void |
attachAsDataStream()
Optimizes all statements as one entity and adds them as transformations to the underlying
StreamExecutionEnvironment . |
execute, explain
StreamStatementSet addInsertSql(String statement)
StatementSet
INSERT INTO
SQL statement.addInsertSql
in interface StatementSet
StreamStatementSet addInsert(String targetPath, Table table)
StatementSet
Table
object should be
written to a table (backed by a DynamicTableSink
) that was registered under the
specified path.
See the documentation of TableEnvironment.useDatabase(String)
or TableEnvironment.useCatalog(String)
for the rules on the path resolution.
addInsert
in interface StatementSet
StreamStatementSet addInsert(String targetPath, Table table, boolean overwrite)
StatementSet
Table
object should be
written to a table (backed by a DynamicTableSink
) that was registered under the
specified path.
See the documentation of TableEnvironment.useDatabase(String)
or TableEnvironment.useCatalog(String)
for the rules on the path resolution.
addInsert
in interface StatementSet
overwrite
- Indicates whether existing data should be overwritten.StreamStatementSet addInsert(TableDescriptor targetDescriptor, Table table)
StatementSet
Table
object should be
written to a table (backed by a DynamicTableSink
) expressed via the given TableDescriptor
.
The given descriptor
is registered as an inline (i.e. anonymous)
temporary catalog table (see TableEnvironment.createTemporaryTable(String,
TableDescriptor)
. Then a statement is added to the statement set that inserts the Table
object's pipeline into that temporary table.
This method allows to declare a Schema
for the sink descriptor. The declaration is
similar to a CREATE TABLE
DDL in SQL and allows to:
DataType
It is possible to declare a schema without physical/regular columns. In this case, those columns will be automatically derived and implicitly put at the beginning of the schema declaration.
Examples:
StatementSet stmtSet = tEnv.createStatementSet();
Table sourceTable = tEnv.from("SourceTable");
TableDescriptor sinkDescriptor = TableDescriptor.forConnector("blackhole")
.schema(Schema.newBuilder()
// …
.build())
.build();
stmtSet.addInsert(sinkDescriptor, sourceTable);
addInsert
in interface StatementSet
StreamStatementSet addInsert(TableDescriptor targetDescriptor, Table table, boolean overwrite)
StatementSet
Table
object should be
written to a table (backed by a DynamicTableSink
) expressed via the given TableDescriptor
.
The given descriptor
is registered as an inline (i.e. anonymous)
temporary catalog table (see TableEnvironment.createTemporaryTable(String,
TableDescriptor)
. Then a statement is added to the statement set that inserts the Table
object's pipeline into that temporary table.
This method allows to declare a Schema
for the sink descriptor. The declaration is
similar to a CREATE TABLE
DDL in SQL and allows to:
DataType
It is possible to declare a schema without physical/regular columns. In this case, those columns will be automatically derived and implicitly put at the beginning of the schema declaration.
Examples:
StatementSet stmtSet = tEnv.createStatementSet();
Table sourceTable = tEnv.from("SourceTable");
TableDescriptor sinkDescriptor = TableDescriptor.forConnector("blackhole")
.schema(Schema.newBuilder()
// …
.build())
.build();
stmtSet.addInsert(sinkDescriptor, sourceTable, true);
addInsert
in interface StatementSet
overwrite
- Indicates whether existing data should be overwritten.void attachAsDataStream()
StreamExecutionEnvironment
.
Use StreamExecutionEnvironment.execute()
to execute them.
The added statements will be cleared after calling this method.
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.