# Get an attachment SQL result

Launch stage: GA

`GET /api/2.0/genie/spaces/{space_id}/conversations/{conversation_id}/messages/{message_id}/attachments/{attachment_id}/query-result`

Get the result of SQL query if the message has a query attachment.
 This is only available if a message has a query attachment and the message status is `EXECUTING_QUERY` OR `COMPLETED`.

API scopes: genie

## Path parameters

- `space_id` (string, uuid, required)
  Genie space ID
  Example: `e1ef34712a29169db030324fd0e1df5f`
- `conversation_id` (string, uuid, required)
  Conversation ID
  Example: `e1ef34712a29169db030324fd0e1df5f`
- `message_id` (string, uuid, required)
  Message ID
  Example: `e1ef34712a29169db030324fd0e1df5f`
- `attachment_id` (string, uuid, required)
  Attachment ID
  Example: `e1ef34712a29169db030324fd0e1df5f`

## Returns

- `statement_response` (object, optional)
  SQL Statement Execution response. See [Get status, manifest, and result first chunk](:method:statementexecution/getstatement) for more details.
  - `statement_id` (string, optional)
    The statement ID is returned upon successfully submitting a SQL statement, and is a required
     reference for all subsequent calls.
  - `status` (object, optional)
    - `state` (string, optional)
      Statement execution state:
       - `PENDING`: waiting for warehouse
       - `RUNNING`: running
       - `SUCCEEDED`: execution was successful, result data available for fetch
       - `FAILED`: execution failed; reason for failure described in accompanying error message
       - `CANCELED`: user canceled; can come from explicit cancel call, or timeout with
       `on_wait_timeout=CANCEL`
       - `CLOSED`: execution successful, and statement closed; result no longer available for fetch
      Possible values:
      - `STATE_UNSPECIFIED`
      - `PENDING`
      - `RUNNING`
      - `SUCCEEDED`
      - `FAILED`
      - `CANCELED`
      - `CLOSED`
    - `error` (object, optional)
      - `error_code` (string, optional)
        Possible values:
        - `UNKNOWN`
        - `INTERNAL_ERROR`
        - `TEMPORARILY_UNAVAILABLE`
        - `IO_ERROR`
        - `BAD_REQUEST`
        - `SERVICE_UNDER_MAINTENANCE`
        - `WORKSPACE_TEMPORARILY_UNAVAILABLE`
        - `DEADLINE_EXCEEDED`
        - `CANCELLED`
        - `RESOURCE_EXHAUSTED`
        - `ABORTED`
        - `NOT_FOUND`
        - `ALREADY_EXISTS`
        - `UNAUTHENTICATED`
        - `UNAVAILABLE`
        - `INVALID_PARAMETER_VALUE`
        - `ENDPOINT_NOT_FOUND`
        - `MALFORMED_REQUEST`
        - `INVALID_STATE`
        - `PERMISSION_DENIED`
        - `FEATURE_DISABLED`
        - `CUSTOMER_UNAUTHORIZED`
        - `REQUEST_LIMIT_EXCEEDED`
        - `RESOURCE_CONFLICT`
        - `UNPARSEABLE_HTTP_ERROR`
        - `NOT_IMPLEMENTED`
        - `DATA_LOSS`
        - `INVALID_STATE_TRANSITION`
        - `COULD_NOT_ACQUIRE_LOCK`
        - `RESOURCE_ALREADY_EXISTS`
        - `RESOURCE_DOES_NOT_EXIST`
        - `QUOTA_EXCEEDED`
        - `MAX_BLOCK_SIZE_EXCEEDED`
        - `MAX_READ_SIZE_EXCEEDED`
        - `PARTIAL_DELETE`
        - `MAX_LIST_SIZE_EXCEEDED`
        - `DRY_RUN_FAILED`
        - `RESOURCE_LIMIT_EXCEEDED`
        - `DIRECTORY_NOT_EMPTY`
        - `DIRECTORY_PROTECTED`
        - `MAX_NOTEBOOK_SIZE_EXCEEDED`
        - `MAX_CHILD_NODE_SIZE_EXCEEDED`
        - `SEARCH_QUERY_TOO_LONG`
        - `SEARCH_QUERY_TOO_SHORT`
        - `MANAGED_RESOURCE_GROUP_DOES_NOT_EXIST`
        - `PERMISSION_NOT_PROPAGATED`
        - `DEPLOYMENT_TIMEOUT`
        - `GIT_CONFLICT`
        - `GIT_UNKNOWN_REF`
        - `GIT_SENSITIVE_TOKEN_DETECTED`
        - `GIT_URL_NOT_ON_ALLOW_LIST`
        - `GIT_REMOTE_ERROR`
        - `PROJECTS_OPERATION_TIMEOUT`
        - `IPYNB_FILE_IN_REPO`
        - `INSECURE_PARTNER_RESPONSE`
        - `MALFORMED_PARTNER_RESPONSE`
        - `METASTORE_DOES_NOT_EXIST`
        - `DAC_DOES_NOT_EXIST`
        - `CATALOG_DOES_NOT_EXIST`
        - `SCHEMA_DOES_NOT_EXIST`
        - `TABLE_DOES_NOT_EXIST`
        - `SHARE_DOES_NOT_EXIST`
        - `RECIPIENT_DOES_NOT_EXIST`
        - `STORAGE_CREDENTIAL_DOES_NOT_EXIST`
        - `EXTERNAL_LOCATION_DOES_NOT_EXIST`
        - `PRINCIPAL_DOES_NOT_EXIST`
        - `PROVIDER_DOES_NOT_EXIST`
        - `METASTORE_ALREADY_EXISTS`
        - `DAC_ALREADY_EXISTS`
        - `CATALOG_ALREADY_EXISTS`
        - `SCHEMA_ALREADY_EXISTS`
        - `TABLE_ALREADY_EXISTS`
        - `SHARE_ALREADY_EXISTS`
        - `RECIPIENT_ALREADY_EXISTS`
        - `STORAGE_CREDENTIAL_ALREADY_EXISTS`
        - `EXTERNAL_LOCATION_ALREADY_EXISTS`
        - `PROVIDER_ALREADY_EXISTS`
        - `CATALOG_NOT_EMPTY`
        - `SCHEMA_NOT_EMPTY`
        - `METASTORE_NOT_EMPTY`
        - `PROVIDER_SHARE_NOT_ACCESSIBLE`
      - `message` (string, optional)
      - `stack_trace` (string, optional)
    - `sql_state` (string, optional)
      SQLSTATE error code returned when the statement execution fails.
       Only populated when the statement status is `FAILED`.
  - `manifest` (object, optional)
    - `format` (string, optional)
      Possible values:
      - `FORMAT_UNSPECIFIED`
      - `JSON_ARRAY`
      - `ARROW_STREAM`
      - `CSV`
    - `schema` (object, optional)
      - `column_count` (int32, optional)
      - `columns` (array of object, optional)
        - `name` (string, optional)
          Name of Column.
        - `type_text` (string, optional)
          Full data type specification as SQL/catalogString text.
        - `type_name` (string, optional)
          Possible values:
          - `BOOLEAN`
          - `BYTE`
          - `SHORT`
          - `INT`
          - `LONG`
          - `FLOAT`
          - `DOUBLE`
          - `DATE`
          - `TIMESTAMP`
          - `STRING`
          - `BINARY`
          - `DECIMAL`
          - `INTERVAL`
          - `ARRAY`
          - `STRUCT`
          - `MAP`
          - `CHAR`
          - `NULL`
          - `USER_DEFINED_TYPE`
          - `TIMESTAMP_NTZ`
          - `VARIANT`
          - `GEOMETRY`
          - `GEOGRAPHY`
          - `TABLE_TYPE`
        - `position` (int32, optional)
          Ordinal position of column (starting at position 0).
        - `type_precision` (int32, optional)
          Digits of precision; required for DecimalTypes.
        - `type_scale` (int32, optional)
          Digits to right of decimal; Required for DecimalTypes.
        - `type_interval_type` (string, optional)
          Format of IntervalType.
        - `type_json` (string, optional)
          Full data type specification, JSON-serialized.
        - `comment` (string, optional)
          User-provided free-form text description.
        - `nullable` (boolean, optional)
          Whether field may be Null (default: true).
          Default: `true`
        - `partition_index` (int32, optional)
          Partition index for column.
        - `mask` (object, optional)
          - `function_name` (string, optional)
            The full name of the column mask SQL UDF.
          - `using_column_names` (array of string, optional)
            The list of additional table columns to be passed as input to the column mask function. The
             first arg of the mask function should be of the type of the column being masked and the
             types of the rest of the args should match the types of columns in 'using_column_names'.
          - `using_arguments` (array of object, optional, Deprecated)
            The list of table columns or literals to be passed as additional arguments to a column mask
             function, carrying the type (column reference vs constant literal) of each argument.
             Deprecated: use using_column_names instead.
            - `column` (string, optional)
              A column reference.
            - `constant` (string, optional)
              A constant literal.
    - `total_chunk_count` (int32, optional)
      The total number of chunks that the result set has been divided into.
    - `chunks` (array of object, optional)
      Array of result set chunk metadata.
      - `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`.
    - `total_row_count` (int64, optional)
      The total number of rows in the result set.
    - `total_byte_count` (int64, optional)
      The total number of bytes in the result set. This field is not available when using `INLINE`
       disposition.
    - `truncated` (boolean, optional)
      Indicates whether the result is truncated due to `row_limit` or `byte_limit`.
  - `result` (object, optional)
    - `external_links` (array of object, optional)
      - `external_link` (string, optional)
        A short-lived cloud-storage 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:** On AWS, this is a presigned URL.
        **Azure:** On Azure, this is a SAS URL.
        **GCP:** On GCP, this is a signed URL.
      - `expiration` (string, date-time, 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 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`.
      - `values` (array of object, optional)
        Repeated field of dynamically typed values.
        - `null_value` (string, optional)
          Represents a null value.
          Possible values:
          - `NULL_VALUE`
        - `number_value` (double, optional)
          Represents a double value.
        - `string_value` (string, optional)
          Represents a string value.
        - `bool_value` (boolean, optional)
          Represents a boolean value.
        - `struct_value` (object, optional)
          Represents a structured value.
          - `fields` (array of object, optional)
            Unordered map of dynamically typed values.
            - `key` (string, optional)
    - `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

```json
{
  "statement_response": {
    "statement_id": "string",
    "status": {},
    "manifest": {},
    "result": {}
  }
}
```

