Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . s3api ]

select-object-content

Description

This operation filters the contents of an Amazon S3 object based on a simple structured query language (SQL) statement. In the request, along with the SQL expression, you must also specify a data serialization format (JSON, CSV, or Apache Parquet) of the object. Amazon S3 uses this format to parse object data into records, and returns only records that match the specified SQL expression. You must also specify the data serialization format for the response.

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

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

Permissions

You must have s3:GetObject permission for this operation. Amazon S3 Select does not support anonymous access. For more information about permissions, see Specifying Permissions in a Policy in the Amazon Simple Storage Service Developer Guide .

Object Data Formats

You can use Amazon S3 Select to query objects that have the following format properties:

  • CSV, JSON, and Parquet - Objects must be in CSV, JSON, or Parquet format.
  • UTF-8 - UTF-8 is the only encoding type Amazon S3 Select supports.
  • GZIP or BZIP2 - CSV and JSON files can be compressed using GZIP or BZIP2. GZIP and BZIP2 are the only compression formats that Amazon S3 Select supports for CSV and JSON files. Amazon S3 Select supports columnar compression for Parquet using GZIP or Snappy. Amazon S3 Select does not support whole-object compression for Parquet objects.
  • Server-side encryption - Amazon S3 Select supports querying objects that are protected with server-side encryption. For objects that are encrypted with customer-provided encryption keys (SSE-C), you must use HTTPS, and you must use the headers that are documented in the GetObject . For more information about SSE-C, see Server-Side Encryption (Using Customer-Provided Encryption Keys) in the Amazon Simple Storage Service Developer Guide . For objects that are encrypted with Amazon S3 managed encryption keys (SSE-S3) and customer master keys (CMKs) stored in AWS Key Management Service (SSE-KMS), server-side encryption is handled transparently, so you don't need to specify anything. For more information about server-side encryption, including SSE-S3 and SSE-KMS, see Protecting Data Using Server-Side Encryption in the Amazon Simple Storage Service Developer Guide .
Working with the Response Body

Given the response size 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, see RESTSelectObjectAppendix .

GetObject Support

The SelectObjectContent operation does not support the following GetObject functionality. For more information, see GetObject .

  • Range : While you can specify a scan range for a Amazon S3 Select request, see SelectObjectContentRequest$ScanRange in the request parameters below, you cannot specify the range of bytes of an object to return.
  • GLACIER, DEEP_ARCHIVE and REDUCED_REDUNDANCY storage classes: You cannot specify the GLACIER, DEEP_ARCHIVE, or REDUCED_REDUNDANCY storage classes. For more information, about storage classes see Storage Classes in the Amazon Simple Storage Service Developer Guide .
Special Errors

For a list of special errors for this operation and for general information about Amazon S3 errors and a list of error codes, see ErrorResponses

Related Resources
  • GetObject
  • GetBucketLifecycleConfiguration
  • PutBucketLifecycleConfiguration

See also: AWS API Documentation

See 'aws help' for descriptions of global parameters.

Synopsis

  select-object-content
--bucket <value>
--key <value>
[--sse-customer-algorithm <value>]
[--sse-customer-key <value>]
[--sse-customer-key-md5 <value>]
--expression <value>
--expression-type <value>
[--request-progress <value>]
--input-serialization <value>
--output-serialization <value>
[--scan-range <value>]
outfile <value>

Options

--bucket (string)

The S3 bucket.

--key (string)

The object key.

--sse-customer-algorithm (string)

The SSE Algorithm used to encrypt the object. For more information, see Server-Side Encryption (Using Customer-Provided Encryption Keys .

--sse-customer-key (string)

The SSE Customer Key. For more information, see Server-Side Encryption (Using Customer-Provided Encryption Keys .

--sse-customer-key-md5 (string)

The SSE Customer Key MD5. For more information, see Server-Side Encryption (Using Customer-Provided Encryption Keys .

--expression (string)

The expression that is used to query the object.

--expression-type (string)

The type of the provided expression (for example., SQL).

Possible values:

  • SQL

--request-progress (structure)

Specifies if periodic request progress information should be enabled.

Shorthand Syntax:

Enabled=boolean

JSON Syntax:

{
  "Enabled": true|false
}

--input-serialization (structure)

Describes the format of the data in the object that is being queried.

Shorthand Syntax:

CSV={FileHeaderInfo=string,Comments=string,QuoteEscapeCharacter=string,RecordDelimiter=string,FieldDelimiter=string,QuoteCharacter=string,AllowQuotedRecordDelimiter=boolean},CompressionType=string,JSON={Type=string},Parquet={}

JSON Syntax:

{
  "CSV": {
    "FileHeaderInfo": "USE"|"IGNORE"|"NONE",
    "Comments": "string",
    "QuoteEscapeCharacter": "string",
    "RecordDelimiter": "string",
    "FieldDelimiter": "string",
    "QuoteCharacter": "string",
    "AllowQuotedRecordDelimiter": true|false
  },
  "CompressionType": "NONE"|"GZIP"|"BZIP2",
  "JSON": {
    "Type": "DOCUMENT"|"LINES"
  },
  "Parquet": {

  }
}

--output-serialization (structure)

Describes the format of the data that you want Amazon S3 to return in response.

Shorthand Syntax:

CSV={QuoteFields=string,QuoteEscapeCharacter=string,RecordDelimiter=string,FieldDelimiter=string,QuoteCharacter=string},JSON={RecordDelimiter=string}

JSON Syntax:

{
  "CSV": {
    "QuoteFields": "ALWAYS"|"ASNEEDED",
    "QuoteEscapeCharacter": "string",
    "RecordDelimiter": "string",
    "FieldDelimiter": "string",
    "QuoteCharacter": "string"
  },
  "JSON": {
    "RecordDelimiter": "string"
  }
}

--scan-range (structure)

Specifies the byte range of the object to get the records from. A record is processed when its first byte is contained by the range. This parameter is optional, but when specified, it must not be empty. See RFC 2616, Section 14.35.1 about how to specify the start and end of the range.

ScanRange may be used in the following ways:
  • scanrangestart50/startend100/end/scanrange - process only the records starting between the bytes 50 and 100 (inclusive, counting from zero)
  • scanrangestart50/start/scanrange - process only the records starting after the byte 50
  • scanrangeend50/end/scanrange - process only the records within the last 50 bytes of the file.

Shorthand Syntax:

Start=long,End=long

JSON Syntax:

{
  "Start": long,
  "End": long
}

outfile (string) Filename where the records will be saved

See 'aws help' for descriptions of global parameters.

Output

This command generates no output. The selected object content is written to the specified outfile.