@Internal public class StatementSetImpl<E extends TableEnvironmentInternal> extends Object implements StatementSet
StatementSet
.Modifier and Type | Field and Description |
---|---|
protected List<ModifyOperation> |
operations |
protected E |
tableEnvironment |
Modifier | Constructor and Description |
---|---|
protected |
StatementSetImpl(E tableEnvironment) |
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.
|
String |
getJsonPlan()
Get the json plan of the all statements and Tables as a batch.
|
protected final E extends TableEnvironmentInternal tableEnvironment
protected final List<ModifyOperation> operations
protected StatementSetImpl(E tableEnvironment)
public StatementSet addInsertSql(String statement)
StatementSet
INSERT INTO
SQL statement.addInsertSql
in interface StatementSet
public StatementSet 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
public StatementSet 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.public StatementSet 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
public StatementSet 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.public String explain(ExplainDetail... extraDetails)
StatementSet
explain
in interface StatementSet
extraDetails
- The extra explain details which the explain result should include, e.g.
estimated cost, changelog mode for streaming, displaying execution plan in json formatpublic TableResult execute()
StatementSet
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.
execute
in interface StatementSet
@Experimental public String getJsonPlan()
The json plan is the string json representation of an optimized ExecNode plan for the statements and Tables. An ExecNode plan can be serialized to json plan, and a json plan can be deserialized to an ExecNode plan.
The added statements and Tables will NOT be cleared when executing this method.
NOTES: This is an experimental feature now.
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.