Skip to content

Honor gzip and mime_type on SFTPToGCS stream path - #72132

Merged
potiuk merged 1 commit into
apache:mainfrom
Vamsi-klu:fix/34995-sftp-gcs-stream-gzip-docs
Aug 27, 2026
Merged

Honor gzip and mime_type on SFTPToGCS stream path#72132
potiuk merged 1 commit into
apache:mainfrom
Vamsi-klu:fix/34995-sftp-gcs-stream-gzip-docs

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What is the change?

SFTPToGCSOperator with use_stream=True now applies gzip and mime_type, which the stream path silently dropped. I also documented use_stream in the how-to page and floored the google provider's sftp extra at apache-airflow-providers-sftp>=5.3.3.

Why did I do it?

closes: #34995

#48107 added use_stream, but only the tempfile path honored compression and content type. The stream unit test asserted just upload.assert_not_called(), so a regression back to tempfile would still pass. The docs never mentioned the flag, and sftp 5.1.0's retrieve_file only covered BytesIO, not BlobWriter.

How did I do it?

I set the blob's content_type from mime_type before opening the writer. When gzip=True, I wrap the writer in gzip.GzipFile and open the blob with ignore_flush=True, because GzipFile.close() calls flush and BlobWriter.flush() raises otherwise. Content-Encoding is not set, matching the tempfile path and GCSHook.upload. The default stays use_stream=False.

What's the impact?

Streamed uploads get the same object metadata and compression as tempfile uploads. Installing the google provider's sftp extra now pulls sftp 5.3.3 or newer.

What's the test plan?

Tightened unit tests in test_sftp_to_gcs.py: stream path never touches NamedTemporaryFile, the retrieve_file sink is file-like, gzip wraps the writer with ignore_flush=True, and wildcard plus stream. One system-test task runs with use_stream=True, with a matching OpenLineage fixture.


Was generative AI tooling used to co-author this PR?
  • Yes

Generated-by: Cursor Grok 4.6 following the guidelines

use_stream already skips the tempfile. It still dropped gzip and
mime_type, and docs never mentioned the flag. Apply those on the
blob writer, pin tests against a tempfile regression, and floor
the sftp extra at 5.3.3 for BlobWriter getfo.

closes: apache#34995
@Vamsi-klu
Vamsi-klu requested a review from shahar1 as a code owner August 27, 2026 07:01
@boring-cyborg boring-cyborg Bot added area:providers kind:documentation provider:google Google (including GCP) related issues labels Aug 27, 2026
@potiuk
potiuk merged commit 14fd820 into apache:main Aug 27, 2026
109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers kind:documentation provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Streaming from SFTP to GCS in SFTPToGCSOperator

2 participants