@Internal public class TableResultImpl extends Object implements TableResultInternal
TableResult
.Modifier and Type | Class and Description |
---|---|
static class |
TableResultImpl.Builder
Builder for creating a
TableResultImpl . |
TABLE_RESULT_OK
Modifier and Type | Method and Description |
---|---|
void |
await()
Wait if necessary until the data is ready.
|
void |
await(long timeout,
TimeUnit unit)
Wait if necessary for at most the given time for the data to be ready.
|
static TableResultImpl.Builder |
builder() |
CloseableIterator<Row> |
collect()
Get the result contents as a closeable row iterator.
|
CloseableIterator<RowData> |
collectInternal()
Returns an iterator that returns the iterator with the internal row data type.
|
CachedPlan |
getCachedPlan() |
Optional<JobClient> |
getJobClient()
For DML and DQL statement, return the
JobClient which associates the submitted Flink
job. |
ResolvedSchema |
getResolvedSchema()
Returns the schema of the result.
|
ResultKind |
getResultKind()
Return the
ResultKind which represents the result type. |
RowDataToStringConverter |
getRowDataToStringConverter() |
void |
print()
Print the result contents as tableau form to client console.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTableSchema
public Optional<JobClient> getJobClient()
TableResult
JobClient
which associates the submitted Flink
job. For other statements (e.g. DDL, DCL) return empty.getJobClient
in interface TableResult
public void await() throws InterruptedException, ExecutionException
TableResult
For a select operation, this method will wait until the first row can be accessed locally. For an insert operation, this method will wait for the job to finish, because the result contains only one row. For other operations, this method will return immediately, because the result is already available locally.
await
in interface TableResult
InterruptedException
- if the operation was interrupted while waitingExecutionException
- if a problem occurredpublic void await(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
TableResult
For a select operation, this method will wait until the first row can be accessed locally. For an insert operation, this method will wait for the job to finish, because the result contains only one row. For other operations, this method will return immediately, because the result is already available locally.
await
in interface TableResult
timeout
- the maximum time to waitunit
- the time unit of the timeout argumentInterruptedException
- if the operation was interrupted while waitingExecutionException
- if a problem occurredTimeoutException
- if the wait timed outpublic ResolvedSchema getResolvedSchema()
TableResult
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 column name of `SHOW MODULES` is "module 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 | | extras | STRING | extras such as computed or metadata column information, 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.
getResolvedSchema
in interface TableResult
public ResultKind getResultKind()
TableResult
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
.
getResultKind
in interface TableResult
public CloseableIterator<Row> collect()
TableResult
NOTE:
TableResult.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
}
This method has slightly different behaviors under different checkpointing settings (to
enable checkpointing for a streaming job, set checkpointing properties through TableConfig
).
In order to fetch result to local, you can call either TableResult.collect()
and TableResult.print()
. But, they can't be called both on the same TableResult
instance, because
the result can only be accessed once.
collect
in interface TableResult
public CloseableIterator<RowData> collectInternal()
TableResultInternal
collectInternal
in interface TableResultInternal
public RowDataToStringConverter getRowDataToStringConverter()
getRowDataToStringConverter
in interface TableResultInternal
@Nullable public CachedPlan getCachedPlan()
getCachedPlan
in interface TableResultInternal
public void print()
TableResult
This method has slightly different behaviors under different checkpointing settings (to
enable checkpointing for a streaming job, set checkpointing properties through TableConfig
).
In order to fetch result to local, you can call either TableResult.collect()
and TableResult.print()
. But, they can't be called both on the same TableResult
instance, because
the result can only be accessed once.
print
in interface TableResult
public static TableResultImpl.Builder builder()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.