Method: Aws::S3::Client#select_object_content
- Defined in:
- lib/aws-sdk-s3/client.rb
#select_object_content(params = {}) ⇒ Types::SelectObjectContentOutput
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_REDUNDANCYstorage classes. For more information, about storage classes see- Storage Classes][6
-
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
[1]: docs.aws.amazon.com/AmazonS3/latest/dev/selecting-content-from-objects.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/s3-glacier-select-sql-reference.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html [4]: docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html [5]: docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html [6]: docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#storage-class-intro
11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 |
# File 'lib/aws-sdk-s3/client.rb', line 11234 def select_object_content(params = {}, = {}, &block) params = params.dup event_stream_handler = case handler = params.delete(:event_stream_handler) when EventStreams::SelectObjectContentEventStream then handler when Proc then EventStreams::SelectObjectContentEventStream.new.tap(&handler) when nil then EventStreams::SelectObjectContentEventStream.new else msg = "expected :event_stream_handler to be a block or "\ "instance of Aws::S3::EventStreams::SelectObjectContentEventStream"\ ", got `#{handler.inspect}` instead" raise ArgumentError, msg end yield(event_stream_handler) if block_given? req = build_request(:select_object_content, params) req.context[:event_stream_handler] = event_stream_handler req.handlers.add(Aws::Binary::DecodeHandler, priority: 95) req.send_request(, &block) end |