Honor gzip and mime_type on SFTPToGCS stream path - #72132
Merged
potiuk merged 1 commit intoAug 27, 2026
Conversation
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
potiuk
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the change?
SFTPToGCSOperatorwithuse_stream=Truenow appliesgzipandmime_type, which the stream path silently dropped. I also documenteduse_streamin the how-to page and floored the google provider'ssftpextra atapache-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 justupload.assert_not_called(), so a regression back to tempfile would still pass. The docs never mentioned the flag, and sftp 5.1.0'sretrieve_fileonly coveredBytesIO, notBlobWriter.How did I do it?
I set the blob's
content_typefrommime_typebefore opening the writer. Whengzip=True, I wrap the writer ingzip.GzipFileand open the blob withignore_flush=True, becauseGzipFile.close()calls flush andBlobWriter.flush()raises otherwise.Content-Encodingis not set, matching the tempfile path andGCSHook.upload. The default staysuse_stream=False.What's the impact?
Streamed uploads get the same object metadata and compression as tempfile uploads. Installing the google provider's
sftpextra 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 touchesNamedTemporaryFile, theretrieve_filesink is file-like, gzip wraps the writer withignore_flush=True, and wildcard plus stream. One system-test task runs withuse_stream=True, with a matching OpenLineage fixture.Was generative AI tooling used to co-author this PR?
Generated-by: Cursor Grok 4.6 following the guidelines