AsyncJob (Snowpark Java API Reference 1.20.0)

Package com.snowflake.snowpark_java

## Class AsyncJob

- java.lang.Object
- - com.snowflake.snowpark_java.AsyncJob

- Direct Known Subclasses:
    `TypedAsyncJob`

      public class AsyncJob
      extends java.lang.Object

  Provides a way to track an asynchronous query in Snowflake.

  You can use this object to check the status of an asynchronous query and retrieve the results.

  To check the status of an asynchronous query that you submitted earlier, call `Session.createAsyncJob`, and pass in the query ID. This returns an `AsyncJob` object that you can use to check the status of the query and retrieve the query results.

  Since:
    1.2.0

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `cancel()` | Cancel the underlying query if it is running.
    `java.util.Iterator<Row>` | `getIterator()` | Returns an iterator of Row objects that you can use to retrieve the results for the underlying query.
    `java.util.Iterator<Row>` | `getIterator​(int maxWaitTimeInSeconds)` | Returns an iterator of Row objects that you can use to retrieve the results for the underlying query.
    `java.lang.String` | `getQueryId()` | Get the query ID for the underlying query.
    `Row[]` | `getRows()` | Returns an Array of Row objects that represent the results of the underlying query.
    `Row[]` | `getRows​(int maxWaitTimeInSeconds)` | Returns an Array of Row objects that represent the results of the underlying query.
    `boolean` | `isDone()` | Returns true if the underlying query completed.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getQueryId

          public java.lang.String getQueryId()

      Get the query ID for the underlying query.
      Returns:
        a query ID
      Since:
        1.2.0

    - #### getIterator

          public java.util.Iterator<Row> getIterator​(int maxWaitTimeInSeconds)

      Returns an iterator of Row objects that you can use to retrieve the results for the underlying query.

      Unlike the getRows method, this method does not load all data into memory at once.

      Parameters:
        `maxWaitTimeInSeconds` - The maximum number of seconds to wait for the query to complete before attempting to retrieve the results.
      Returns:
        An Iterator of Row objects
      Since:
        1.2.0

    - #### getIterator

          public java.util.Iterator<Row> getIterator()

      Returns an iterator of Row objects that you can use to retrieve the results for the underlying query.

      Unlike the getRows method, this method does not load all data into memory at once.

      The max waiting time is the value of `snowpark_request_timeout_in_seconds` configuration property.

      Returns:
        An Iterator of Row objects
      Since:
        1.2.0

    - #### getRows

          public Row[] getRows​(int maxWaitTimeInSeconds)

      Returns an Array of Row objects that represent the results of the underlying query.
      Parameters:
        `maxWaitTimeInSeconds` - The maximum number of seconds to wait for the query to complete before attempting to retrieve the results.
      Returns:
        An Array of Row objects
      Since:
        1.2.0

    - #### getRows

          public Row[] getRows()

      Returns an Array of Row objects that represent the results of the underlying query.

      The max waiting time is the value of the `snowpark_request_timeout_in_seconds` configuration property.

      Returns:
        An Array of Row objects
      Since:
        1.2.0

    - #### isDone

          public boolean isDone()

      Returns true if the underlying query completed.

      Completion may be due to query success, cancellation or failure, in all of these cases, this method will return true.

      Returns:
        true if this query completed.
      Since:
        1.2.0

    - #### cancel

          public void cancel()

      Cancel the underlying query if it is running.
      Since:
        1.2.0