john-jac opened a new pull request, #65789:
URL: https://github.com/apache/airflow/pull/65789

   ## What does this PR do?
   
   Add a new `S3ReadObjectOperator` that reads an S3 object and returns its 
content as a UTF-8 string. This is the read counterpart to the existing 
`S3CreateObjectOperator`.
   
   ## Motivation
   
   Currently there is no dedicated operator to read an S3 object's content. 
Users must use `PythonOperator` with custom code or use the hook directly. This 
operator provides a first-class way to read S3 objects, consistent with the 
existing S3 operator family.
   
   ## Changes
   
   ### Operator 
(`providers/amazon/src/airflow/providers/amazon/aws/operators/s3.py`)
   - New `S3ReadObjectOperator` class extending `AwsBaseOperator[S3Hook]`
   - Supports both explicit `s3_bucket`/`s3_key` and full `s3://` URL via 
`get_s3_bucket_key()`
   - Delegates to `S3Hook.read_key()` for the actual read
   - Returns content as string (auto-pushed to XCom)
   - OpenLineage support via `get_openlineage_facets_on_start()` (input dataset)
   
   ### Unit Tests 
(`providers/amazon/tests/unit/amazon/aws/operators/test_s3_read_object.py`)
   - `test_execute_reads_object` — full moto integration test
   - `test_execute_calls_read_key` — verifies hook delegation
   - `test_execute_with_s3_url` — tests `s3://` URL parsing
   - `test_execute_empty_object` — edge case
   - `test_get_openlineage_facets_on_start` — parametrized OpenLineage test
   - `test_template_fields` — validates template fields
   
   ### System Test 
(`providers/amazon/tests/system/amazon/aws/example_s3_read_object.py`)
   - Creates S3 bucket and test object
   - Reads with explicit bucket/key and with `s3://` URL
   - Cleans up (delete bucket with `trigger_rule=ALL_DONE`)
   
   ### Documentation (`providers/amazon/docs/operators/s3/s3.rst`)
   - Added "Read an Amazon S3 object" section with example snippets
   
   ^ Add meaningful description above
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to