@PublicEvolving public interface StatementSet
StatementSet
accepts pipelines defined by DML statements or Table
objects. The
planner can optimize all added statements together and then submit them as one job.
The added statements will be cleared when calling the execute()
method.
Modifier and Type | Method and Description |
---|---|
StatementSet |
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. |
StatementSet |
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. |
StatementSet |
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 . |
StatementSet |
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 . |
StatementSet |
addInsertSql(String statement)
Adds an
INSERT INTO SQL statement. |
TableResult |
execute()
Executes all statements as one job.
|
String |
explain(ExplainDetail... extraDetails)
Returns the AST and the execution plan to compute the result of the all statements.
|
StatementSet addInsertSql(String statement)
INSERT INTO
SQL statement.StatementSet addInsert(String targetPath, Table table)
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.
StatementSet addInsert(String targetPath, Table table, boolean overwrite)
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.
overwrite
- Indicates whether existing data should be overwritten.StatementSet addInsert(TableDescriptor targetDescriptor, Table table)
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);
StatementSet addInsert(TableDescriptor targetDescriptor, Table table, boolean overwrite)
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);
overwrite
- Indicates whether existing data should be overwritten.String explain(ExplainDetail... extraDetails)
extraDetails
- The extra explain details which the explain result should include, e.g.
estimated cost, changelog mode for streaming, displaying execution plan in json formatTableResult execute()
The added statements will be cleared after calling this method.
By default, all DML operations are executed asynchronously. Use TableResult.await()
or TableResult.getJobClient()
to monitor the execution. Set
TableConfigOptions.TABLE_DML_SYNC
for always synchronous execution.
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.