godfrey he created FLINK-18337:
----------------------------------

             Summary: Introduce TableResult#await method to wait 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


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 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 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.
         *
         * @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)

Reply via email to