select_object_content
async
¶
select_object_content(
bucket: BucketName,
key: ObjectKey,
expression: Expression,
expression_type: ExpressionType,
input_serialization: InputSerialization,
output_serialization: OutputSerialization,
*,
config_overrides: Optional[AsyncS3ClientConfig] = None,
sse_customer_algorithm: Optional[SSECustomerAlgorithm] = None,
sse_customer_key: Optional[SSECustomerKey] = None,
sse_customer_key_md5: Optional[SSECustomerKeyMD5] = None,
request_progress: Optional[RequestProgress] = None,
scan_range: Optional[ScanRange] = None,
expected_bucket_owner: Optional[AccountId] = None,
) -> AsyncGenerator[SelectObjectContentOutput]
This operation is not supported for directory buckets.
This action 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.
This functionality is not supported for Amazon S3 on Outposts.
For more information about Amazon S3 Select, see Selecting Content from Objects and SELECT Command in the Amazon S3 User Guide.
- Permissions
-
You must have the
s3:GetObjectpermission 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 S3 User 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 S3 User Guide.
For objects that are encrypted with Amazon S3 managed keys (SSE-S3) and Amazon Web Services KMS keys (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 S3 User 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-Encodingheader withchunkedas its value in the response. For more information, see Appendix: SelectObjectContent Response. - GetObject Support
-
The
SelectObjectContentaction does not support the followingGetObjectfunctionality. For more information, see GetObject.-
Range: Although you can specify a scan range for an Amazon S3 Select request (see SelectObjectContentRequest - ScanRange in the request parameters), you cannot specify the range of bytes of an object to return. -
The
GLACIER,DEEP_ARCHIVE, andREDUCED_REDUNDANCYstorage classes, or theARCHIVE_ACCESSandDEEP_ARCHIVE_ACCESSaccess tiers of theINTELLIGENT_TIERINGstorage class: You cannot query objects in theGLACIER,DEEP_ARCHIVE, orREDUCED_REDUNDANCYstorage classes, nor objects in theARCHIVE_ACCESSorDEEP_ARCHIVE_ACCESSaccess tiers of theINTELLIGENT_TIERINGstorage class. For more information about storage classes, see Using Amazon S3 storage classes in the Amazon S3 User Guide.
-
- Special Errors
-
For a list of special errors for this operation, see List of SELECT Object Content Error Codes
The following operations are related to SelectObjectContent:
You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.
Parameters:
-
bucket(BucketName) –The S3 bucket.
-
key(ObjectKey) –The object key.
-
sse_customer_algorithm(Optional[SSECustomerAlgorithm], default:None) –The server-side encryption (SSE) algorithm used to encrypt the object. This parameter is needed only when the object was created using a checksum algorithm. For more information, see Protecting data using SSE-C keys in the Amazon S3 User Guide.
-
sse_customer_key(Optional[SSECustomerKey], default:None) –The server-side encryption (SSE) customer managed key. This parameter is needed only when the object was created using a checksum algorithm. For more information, see Protecting data using SSE-C keys in the Amazon S3 User Guide.
-
sse_customer_key_md5(Optional[SSECustomerKeyMD5], default:None) –The MD5 server-side encryption (SSE) customer managed key. This parameter is needed only when the object was created using a checksum algorithm. For more information, see Protecting data using SSE-C keys in the Amazon S3 User Guide.
-
expression(Expression) –The expression that is used to query the object.
-
expression_type(ExpressionType) –The type of the provided expression (for example, SQL).
-
request_progress(Optional[RequestProgress], default:None) –Specifies if periodic request progress information should be enabled.
-
input_serialization(InputSerialization) –Describes the format of the data in the object that is being queried.
-
output_serialization(OutputSerialization) –Describes the format of the data that you want Amazon S3 to return in response.
-
scan_range(Optional[ScanRange], default:None) –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.
ScanRangemay be used in the following ways:-
- process only the records starting between the bytes 50 and 100 (inclusive, counting from zero)50 100 -
- process only the records starting after the byte 5050 -
- process only the records within the last 50 bytes of the file.50
-
-
expected_bucket_owner(Optional[AccountId], default:None) –The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code
403 Forbidden(access denied).
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_s3/_services/async_s3.py
9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 | |