Appendix: SelectObjectContent Response - Amazon Simple Storage Service (original) (raw)

Description

The Amazon S3 Select operation filters the contents of an Amazon S3 object based on a simple structured query language (SQL) statement. Given the response size of this operation is unknown, Amazon S3 Select streams the response as a series of messages and includes a Transfer-Encoding header with chunked as its value in the response.

For more information about Amazon S3 Select, see Selecting Content from Objects in the Amazon Simple Storage Service User Guide.

For more information about using SQL with Amazon S3 Select, see SQL Reference for Amazon S3 Select and S3 Glacier Select in the Amazon Simple Storage Service User Guide.

Responses

A successful Amazon S3 Select Operation returns 200 OK status code.

This implementation of the operation uses only response headers that are common to most responses. For more information, see Common Response Headers.

Response Body

Since the Amazon S3 Select response size is unknown, Amazon S3 streams the response as a series of messages and includes a Transfer-Encoding header with chunked as its value in the response. The following example shows the response format at the top level:

<Message 1>
<Message 2>
<Message 3>
......
<Message n>

Each message consists of two sections: the prelude and the data. The prelude section consists of 1) the total byte-length of the message, and 2) the combined byte-length of all the headers. The data section consists of 1) the headers, and 2) a payload.

Each section ends with a 4-byte big-endian integer checksum (CRC). Amazon S3 Select uses CRC32 (often referred to as GZIP CRC32) to calculate both CRCs. For more information about CRC32, see GZIP file format specification version 4.3.

Total message overhead including the prelude and both checksums is 16 bytes.

Note

All integer values within messages are in network byte order, or big-endian order.

The following diagram shows the components that make up a message and a header. Note that there are multiple headers per message.

Screenshot of an example message structure showing total byte-length, header byte-length, prelude crc, header, payload, and message crc.

Note

For Amazon S3 Select, the header value type is always 7 (type=String). For this type, the header value consists of two components, a 2-byte big-endian integer length, and a UTF-8 string that is of that byte-length. The following diagram shows the components that make up Amazon S3 Select headers.

Screenshot of the headers structure showing header name byte-length, header name string, header value type, value byte-length and value string.

Payload byte-length calculations (these two calculations are equivalent):

Each message contains the following components:

Each header contains the following components. There can be multiple headers per message.

For Amazon S3 Select, responses can be messages of the following types:

The following sections explain the structure of each message type in more detail.

For sample code and unit tests that use this protocol, see AWS C Event Stream on the GitHub website.

Records Message

Records messages contain three headers, as follows:

Screenshot of an example message structure including the headers for this record type.

Payload specification

Records message payloads can contain a single record, partial records, or multiple records.

Continuation Message

Continuation messages contain two headers, as follows:

Screenshot of an example message structure including the headers for this record type.

Payload specification

Continuation messages have no payload.

Progress Message

Progress messages contain three headers, as follows:

Screenshot of an example message structure including the headers for this record type.

Payload specification

Progress message payload is an XML document containing information about the progress of a request.

For uncompressed files, BytesScanned and BytesProcessed are equal.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<Progress>
     <BytesScanned>512</BytesScanned>
     <BytesProcessed>1024</BytesProcessed>
     <BytesReturned>1024</BytesReturned>
</Progress>

Stats Message

Stats messages contain three headers, as follows:

Screenshot of an example message structure including the headers for this record type.

Payload specification

Stats message payload is an XML document containing information about a request's stats when processing is complete.

For uncompressed files, BytesScanned and BytesProcessed are equal.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<Stats>
     <BytesScanned>512</BytesScanned>
     <BytesProcessed>1024</BytesProcessed>
     <BytesReturned>1024</BytesReturned>
</Stats>

End Message

End messages contain two headers, as follows:

Screenshot of an example message structure including the headers for this record type.

Payload specification

End messages have no payload.

Request Level Error Message

Request-level error messages contain three headers, as follows:

Screenshot of an example message structure including the headers for this record type.

For a list of possible error codes and error messages, see the List of SELECT Object Content Error Codes.

Payload specification

Request-level error messages have no payload.