Skip to content

get_query_result_stream

get_query_result_stream(
    query_execution_id: QueryExecutionId,
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    range: Optional[RangeHeaderString] = None,
) -> Generator[GetQueryResultStreamOutput]

Returns query results as a raw binary stream for a single query execution specified by QueryExecutionId. Streams the raw result data in Apache Arrow Inter-Process Communication (IPC) Stream format without transformation. Use StartQueryExecution to run a query.

Parameters:

  • query_execution_id (QueryExecutionId) –

    The unique ID of the query execution.

  • range (Optional[RangeHeaderString], default: None ) –

    An optional byte range header. Format: bytes=N-M. When specified, returns HTTP 206 with the requested byte slice.

Raises:

Source code in docs_src/capo_athena/_services/athena.py
@contextmanager
def get_query_result_stream(
    self,
    query_execution_id: "capo_athena.types.query_execution_id.QueryExecutionId",
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    range: Optional[
        "capo_athena.types.range_header_string.RangeHeaderString"
    ] = None,
) -> "Generator[capo_athena.types.get_query_result_stream_output.GetQueryResultStreamOutput]":
    """<p>Returns query results as a raw binary stream for a single query execution specified by <code>QueryExecutionId</code>. Streams the raw result data in Apache Arrow Inter-Process Communication (IPC) Stream format without transformation. Use <a>StartQueryExecution</a> to run a query.</p>

    Args:
        query_execution_id: <p>The unique ID of the query execution.</p>
        range: <p>An optional byte range header. Format: <code>bytes=N-M</code>. When specified, returns HTTP 206 with the requested byte slice.</p>

    Raises:
        capo_athena.errors.internal_server_exception.InternalServerException: <p>Indicates a platform issue, which may be due to a transient condition or outage.</p>
        capo_athena.errors.invalid_request_exception.InvalidRequestException: <p>Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.</p>
        capo_athena.errors.range_not_satisfiable_exception.RangeNotSatisfiableException: <p>The byte range specified in the <code>Range</code> header cannot be satisfied for the query result. Returned with HTTP status code 416.</p>
        capo_athena.errors.too_many_requests_exception.TooManyRequestsException: <p>Indicates that the request was throttled.</p>
        capo_athena.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_athena.types.get_query_result_stream_input.GetQueryResultStreamInput]",
    ) -> OperationResponse[
        "capo_athena.types.get_query_result_stream_output.GetQueryResultStreamOutput"
    ]:
        import capo_athena._operations.amazon_athena.get_query_result_stream

        output, http_response = (
            capo_athena._operations.amazon_athena.get_query_result_stream.get_query_result_stream(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_athena.types.get_query_result_stream_output.GetQueryResultStreamOutput",
    ) -> dict[str, Any]:
        import capo_athena.types.get_query_result_stream_output

        return capo_athena.types.get_query_result_stream_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetQueryResultStream", redact_output=_redact_output),
    )
    input_: capo_athena.types.get_query_result_stream_input.GetQueryResultStreamInput = {
        "query_execution_id": query_execution_id
    }
    if range is not None:
        input_["range"] = range

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    try:
        yield response.output
    finally:
        response.response.close()