@PublicEvolving public interface TableResult
Modifier and Type | Method and Description |
---|---|
CloseableIterator<Row> |
collect()
Get the result contents as a closeable row iterator.
|
Optional<JobClient> |
getJobClient()
For DML and DQL statement, return the
JobClient which associates the submitted Flink
job. |
ResultKind |
getResultKind()
Return the
ResultKind which represents the result type. |
TableSchema |
getTableSchema()
Get the schema of result.
|
void |
print()
Print the result contents as tableau form to client console.
|
Optional<JobClient> getJobClient()
JobClient
which associates the submitted Flink
job. For other statements (e.g. DDL, DCL) return empty.TableSchema getTableSchema()
The schema of DDL, USE, EXPLAIN:
+-------------+-------------+----------+ | column name | column type | comments | +-------------+-------------+----------+ | result | STRING | | +-------------+-------------+----------+
The schema of SHOW:
+---------------+-------------+----------+ | column name | column type | comments | +---------------+-------------+----------+ | <object name> | STRING | | +---------------+-------------+----------+ The column name of `SHOW CATALOGS` is "catalog name", the column name of `SHOW DATABASES` is "database name", the column name of `SHOW TABLES` is "table name", the column name of `SHOW VIEWS` is "view name", the column name of `SHOW FUNCTIONS` is "function name".
The schema of DESCRIBE:
+------------------+-------------+-----------------------------------------------------------------------------+ | column name | column type | comments | +------------------+-------------+-----------------------------------------------------------------------------+ | name | STRING | field name | | type | STRING | field type expressed as a String | | null | BOOLEAN | field nullability: true if a field is nullable, else false | | key | BOOLEAN | key constraint: 'PRI' for primary keys, 'UNQ' for unique keys, else null | | computed column | STRING | computed column: string expression if a field is computed column, else null | | watermark | STRING | watermark: string expression if a field is watermark, else null | +------------------+-------------+-----------------------------------------------------------------------------+
The schema of INSERT: (one column per one sink)
+----------------------------+-------------+-----------------------+ | column name | column type | comments | +----------------------------+-------------+-----------------------+ | (name of the insert table) | BIGINT | the insert table name | +----------------------------+-------------+-----------------------+
The schema of SELECT is the selected field names and types.
ResultKind getResultKind()
ResultKind
which represents the result type.
For DDL operation and USE operation, the result kind is always ResultKind.SUCCESS
.
For other operations, the result kind is always ResultKind.SUCCESS_WITH_CONTENT
.
CloseableIterator<Row> collect()
NOTE:
getJobClient()
.
getJobClient()
is always
empty), and the result is bounded. Do nothing when calling CloseableIterator#close
method.
Recommended code to call CloseableIterator#close method looks like:
TableResult result = tEnv.execute("select ...");
// using try-with-resources statement
try (CloseableIterator<Row> it = result.collect()) {
it... // collect same data
}
For streaming mode, this method guarantees end-to-end exactly-once record delivery which
requires the checkpointing mechanism to be enabled. By default, checkpointing is disabled. To
enable checkpointing, set checkpointing properties (see ExecutionCheckpointingOptions)
through TableConfig.getConfiguration()
.
In order to fetch result to local, you can call either collect()
and print()
. But, they can't be called both on the same TableResult
instance, because
the result can only be accessed once.
void print()
For streaming mode, this method guarantees end-to-end exactly-once record delivery which
requires the checkpointing mechanism to be enabled. By default, checkpointing is disabled. To
enable checkpointing, set checkpointing properties (see ExecutionCheckpointingOptions)
through TableConfig.getConfiguration()
.
In order to fetch result to local, you can call either collect()
and print()
. But, they can't be called both on the same TableResult
instance, because
the result can only be accessed once.
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.