# Get Result Data

Launch stage: GA

`GET /api/2.0/sql/statements/{statement_id}/result/chunks/{chunk_index}`

After the statement execution has `SUCCEEDED`, this request can be used to fetch any chunk by
 index. Whereas the first chunk with `chunk_index=0` is typically fetched with
 `statementexecution/executeStatement` or `statementexecution/getStatement`, this
 request can be used to fetch subsequent chunks. The response structure is identical to the
 nested `result` element described in the `statementexecution/getStatement` request, and
 similarly includes the `next_chunk_index` and `next_chunk_internal_link` fields for simple
 iteration through the result set. Depending on `disposition`, the response returns chunks of
 data either inline, or as links.

API scopes: sql

## Path parameters

- `statement_id` (string, optional)
  The statement ID is returned upon successfully submitting a SQL statement, and is a required
   reference for all subsequent calls.
- `chunk_index` (int32, optional)

## Returns

- `external_links` (array of object, optional)
  - `external_link` (string, optional)
    A  URL pointing to a
     chunk of result data, hosted by an external service, with a short expiration time
     (<= 15 minutes). As this URL contains a temporary credential, it should be considered sensitive
     and the client should not expose this URL in a log.
    **AWS:** A presigned URL pointing to a
    chunk of result data, hosted by an external service, with a short expiration time
    (<= 15 minutes). As this URL contains a temporary credential, it should be considered sensitive
    and the client should not expose this URL in a log.
    **Azure:** A SAS URL pointing to a
    chunk of result data, hosted by an external service, with a short expiration time
    (<= 15 minutes). As this URL contains a temporary credential, it should be considered sensitive
    and the client should not expose this URL in a log.
    **GCP:** A signed URL pointing to a
    chunk of result data, hosted by an external service, with a short expiration time
    (<= 15 minutes). As this URL contains a temporary credential, it should be considered sensitive
    and the client should not expose this URL in a log.
  - `expiration` (string, optional)
    Indicates the date-time that the given external link will expire and
     becomes invalid, after which point a new `external_link` must be requested.
  - `chunk_index` (int32, optional)
    The position within the sequence of result set chunks.
  - `row_offset` (int64, optional)
    The starting row offset within the result set.
  - `row_count` (int64, optional)
    The number of rows within the result chunk.
  - `byte_count` (int64, optional)
    The number of bytes in the result chunk. This field is not available when using `INLINE`
     disposition.
  - `next_chunk_index` (int32, optional)
    When fetching, provides the `chunk_index` for the _next_ chunk. If absent, indicates there are no
     more chunks. The next chunk can be fetched with a
     :method:statementexecution/getstatementresultchunkn request.
  - `next_chunk_internal_link` (string, optional)
    When fetching, provides a link to fetch the _next_ chunk. If absent, indicates there are no more
     chunks. This link is an absolute `path` to be joined with your `$DATABRICKS_HOST`, and should be
     treated as an opaque link. This is an alternative to using `next_chunk_index`.
- `data_array` (array of array of object, optional)
  The `JSON_ARRAY` format is an array of arrays of values, where each non-null value is
   formatted as a string. Null values are encoded as JSON `null`.
- `chunk_index` (int32, optional)
  The position within the sequence of result set chunks.
- `row_offset` (int64, optional)
  The starting row offset within the result set.
- `row_count` (int64, optional)
  The number of rows within the result chunk.
- `byte_count` (int64, optional)
  The number of bytes in the result chunk. This field is not available when using `INLINE`
   disposition.
- `next_chunk_index` (int32, optional)
  When fetching, provides the `chunk_index` for the _next_ chunk. If absent, indicates there are no
   more chunks. The next chunk can be fetched with a
   :method:statementexecution/getstatementresultchunkn request.
- `next_chunk_internal_link` (string, optional)
  When fetching, provides a link to fetch the _next_ chunk. If absent, indicates there are no more
   chunks. This link is an absolute `path` to be joined with your `$DATABRICKS_HOST`, and should be
   treated as an opaque link. This is an alternative to using `next_chunk_index`.

## Response

### EXTERNAL_LINKS, has next chunk

```json
{
  "external_links": [
    {
      "byte_count": 24486486,
      "chunk_index": 0,
      "expiration": "2023-01-30T22:23:23.140Z",
      "external_link": "https://someplace.cloud-provider.com/very/long/path/...",
      "next_chunk_index": 1,
      "next_chunk_internal_link": "/api/2.0/sql/statements/01ee4b3f-4f56-1648-825a-c261d31be5f1/result/chunks/1",
      "row_count": 100,
      "row_offset": 0
    }
  ]
}
```

### EXTERNAL_LINKS, no next chunk

```json
{
  "external_links": [
    {
      "byte_count": 24486486,
      "chunk_index": 0,
      "expiration": "2023-01-30T22:23:23.140Z",
      "external_link": "https://someplace.cloud-provider.com/very/long/path/...",
      "row_count": 100,
      "row_offset": 0
    }
  ]
}
```

### INLINE, JSON_ARRAY, has next chunk

```json
{
  "chunk_index": 0,
  "data_array": [
    [
      "0-54-0.8256375429534709"
    ],
    [
      "// ... 139799 more rows"
    ]
  ],
  "next_chunk_index": 1,
  "next_chunk_internal_link": "/api/2.0/sql/statements/01eda0ed-9149-1648-bb5d-46d635ab7d74/result/chunks/1",
  "row_count": 139800,
  "row_offset": 0
}
```

### INLINE, JSON_ARRAY, no next chunk

```json
{
  "chunk_index": 0,
  "data_array": [
    [
      "0-54-0.8256375429534709"
    ],
    [
      "// ... 139799 more rows"
    ]
  ],
  "row_count": 139800,
  "row_offset": 0
}
```

