[
https://issues.apache.org/jira/browse/FLINK-18337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Timo Walther closed FLINK-18337.
--------------------------------
Fix Version/s: 1.12.0
Resolution: Fixed
Fixed in 1.12.0: 6f2a0412c0eb00adeb494fcc1d68481bdf2dd7b8
> Introduce TableResult#await method to wait for data ready
> ---------------------------------------------------------
>
> Key: FLINK-18337
> URL: https://issues.apache.org/jira/browse/FLINK-18337
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / API
> Reporter: godfrey he
> Assignee: godfrey he
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.12.0
>
>
> Currently, {{TableEnvironment.executeSql()}} method for INSERT statement
> returns TableResult once the job is submitted. Users must use
> {{tableResult.getJobClient.get().getJobExecutionResult(Thread.currentThread().getContextClassLoader).get()}}
> to wait the job finish. This API looks very ugly.
> So this issue aims to introduce {{TableResult#await}} method, the code
> snippet looks like:
> {code:java}
> val tEnv = ...
> // submit the job and wait job finish
> tEnv.executeSql("insert into ...").await()
> {code}
> the suggested new methods are:
> {code:java}
> /**
> * Wait if necessary until the data is ready.
> *
> * <p>For select operation, this method will wait unit the first row
> can be accessed in local.
> * For 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 ready in local.
> *
> * @throws ExecutionException if this future completed exceptionally
> * @throws InterruptedException if the current thread was interrupted
> while waiting
> */
> void await() throws InterruptedException, ExecutionException;
> /**
> * Wait if necessary for at most the given time for the data to be
> ready.
> *
> * <p>For select operation, this method will wait unit the first row
> can be accessed in local.
> * For 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 ready in local.
> *
> * @param timeout the maximum time to wait
> * @param unit the time unit of the timeout argument
> * @throws ExecutionException if this future completed exceptionally
> * @throws InterruptedException if the current thread was interrupted
> while waiting
> * @throws TimeoutException if the wait timed out
> */
> void await(long timeout, TimeUnit unit) throws InterruptedException,
> ExecutionException, TimeoutException;
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)