3 weeks ago
What I'm trying to do
Pull one zip file per day from an external vendor's SFTP server into Databricks. Most are a few hundred MB, but some are several GB. The zips contain .txt files. Ultimately I just need the zip landed somewhere Databricks can read it โ I can handle the extraction separately.
Current approach
A Lakeflow Declarative Pipeline using Auto Loader with the binaryFile format, reading via a Unity Catalog connection:
from pyspark import pipelines as dp
@DP.temporary_view()
def sftp_raw_zips():
return (
spark.readStream.format("cloudFiles")
.option("cloudFiles.format", "binaryFile")
.option("databricks.connection", "sftp_connection")
.option("pathGlobFilter", "*.zip")
.load(sftp_path)
)
A Python UDF then unzips the content column in memory and explodes the .txt entries into rows.
The problem
No file has ever downloaded successfully. The connection itself works โ authentication succeeds and the directory is reachable โ but the run produces nothing and times out after about 10 minutes. Increasing the pipeline cluster's VM size made no difference.
Environment
Any guidance on the right architecture here would be appreciated โ I suspect I'm using the wrong tool for files this size.
3 weeks ago
Hello @ASH1243434
You're right that it's the wrong tool for this. binaryFile loads each whole file into one content byte-array cell. That is capped at about 2 GB (spark.sql.sources.binaryFile.maxLength), and even below the cap a single task has to pull the whole file over SFTP before emitting anything, so a slow transfer looks like a hang or timeout. For "land one big zip per day", skip the DataFrame: copy the file byte-for-byte into a UC volume with a small Python job task, then unzip and ingest from the volume.
On your specific questions:
- The SFTP connector (Auto Loader + databricks.connection) is Public Preview: https://docs.databricks.com/aws/en/ingestion/sftp. It needs DBR 17.3+, and databricks.connection needs 18.2+, so check which runtime your pipeline channel is actually on. The docs don't list file-size limits or a separate fetch timeout.
- Yes, the binaryFile 2 GB limit applies. Anything over it can't fit in one column.
- It works well for many small or medium files (CSV/JSON/text straight into a table). It's a poor fit for single multi-GB archives.
Copy pattern. Run it as a job task on classic compute that uses your static-IP VNet egress, so the vendor allow-list still matches (serverless won't come from those IPs). Install paramiko as a task library:
import io, paramiko
pem = dbutils.secrets.get("vendor_sftp", "private_key")
key = paramiko.RSAKey.from_private_key(io.StringIO(pem))
transport = paramiko.Transport(("sftp.vendor.com", 22))
transport.connect(username=dbutils.secrets.get("vendor_sftp", "user"), pkey=key)
sftp = paramiko.SFTPClient.from_transport(transport)
remote = "/outbound/daily_2026-10-26.zip"
local = "/local_disk0/tmp/daily.zip"
sftp.get(remote, local) # streamed in chunks, never held in memory
sftp.close(); transport.close()
dbutils.fs.cp(f"file:{local}", "/Volumes/main/vendor/landing/daily_2026-10-26.zip")
Pick the file with sftp.listdir_attr() (newest or not yet copied) instead of hard-coding the name. Next, a second task unzips from the volume with Python's zipfile, which streams entries, into a /Volumes/.../extracted/ folder. Point Auto Loader (cloudFiles.format = "text") at that folder, and your pipeline gets ordinary incremental ingestion with no size limits.
3 weeks ago
For this workload, I'd recommend a scheduled Databricks Job using Paramiko โ UC Volume โ ZIP extraction โ Auto Loader.
Although the native Lakeflow SFTP connector supports binaryFile, it doesn't provide a direct raw ZIP-to-Volume transfer option. Using binaryFile would load the entire multi-GB ZIP into a single DataFrame column, introducing file-size and memory limitations.
Below are a few observations from my hands-on testing, along with safeguards worth considering for large-file transfers.
1. Native SFTP connector support
I tested Auto Loader with cloudFiles.format="binaryFile" and an explicit Unity Catalog SFTP connection against Rebex's public SFTP server.
The file was ingested successfully into Delta, with its 379-byte size and SHA-256 checksum matching an independent, host-key-verified Paramiko read.
I also deliberately mismatched the URI port and received SFTP_URI_AND_CREDENTIAL_MISMATCH.PORT_MISMATCH.
So the native ingestion path works for small files in my Databricks serverless workspace.
2. The binaryFile limitation
Upstream Spark's binary-file reader has a default maximum of 2,147,483,647 bytes, and materializes file contents into one binary value.
This makes multi-GB ZIPs a poor fit, but I haven't verified that Databricks' SFTP connector enforces the exact same boundary or that it explains the reported 10-minute timeout.
3. Making the Paramiko โ Volume approach reliable
A few details I'd add to the suggested implementation:
I also validated the downstream ZIP extraction โ Auto Loader โ Delta workflow using synthetic archives:
Scenario Observed result
| First archive | 4 verified rows |
| Replay using the same checkpoint | Still 4 rows |
| Second archive | 5 total verified rows |
| Interrupted extraction | Incomplete output excluded |
| Retry | Successful |
An important finding: a completion manifest doesn't prevent Auto Loader from discovering partial files if it watches the staging directory. The consumer must read only verified, published outputs.
My tests were small correctness validations, I haven't benchmarked multi-GB Paramiko transfers.
4. Timeout investigation
I couldn't find a documented SFTP-specific fetch timeout setting. I'd check the effective Lakeflow pipeline runtime, URI/connection match, pipeline event and executor logs, and vendor SFTP logs to identify where the transfer actually stops.
Overall, I'd keep the suggested Databricks-native solution, but make transfer verification and publication safety explicit. The native connector works for supported file ingestion, the separate Python transfer step is better suited to landing an original large ZIP unchanged.
References:
3 weeks ago
Hi, your instinct is right. For multi-GB zips, this isn't the right tool.
1. Is SFTP through databricks.connection supported? Yes. The SFTP connector is part of Lakeflow Connect and is built on Auto Loader. Things to know:
databricks.connection needs DBR 18.2 or later.
SFTP only works through Auto Loader / read_files. spark.read, COPY INTO and dbutils.fs.ls don't support it.
cleanSource isn't supported.
2. Does the 2 GB binaryFile limit apply? Yes. Each file lands in one content column, which is capped at 2 GB. But going over it usually gives a clear "exceeds the max length allowed" error, not a timeout. Since even your smaller files never land, check these first:
SFTP session limits: each Auto Loader task opens its own SFTP session. If the vendor caps concurrent sessions, reads can hang. Try a single worker and cloudFiles.maxFilesPerTrigger = 1.
Temporary view: @DP.temporary_view doesn't store anything, so make sure a table reads from it.
Quick test: in a notebook, run the stream selecting only path and length. If that works, the problem is downloading the file.
3. Recommended pattern Land the zip as a file, then let Auto Loader do what it's best at:
A small scheduled job on single-node classic compute, so it uses your allow-listed IPs, downloads the zip with paramiko to /local_disk0. It unzips there, then copies the files to a Unity Catalog volume. Unzip on local disk first because volumes don't support random writes.
Auto Loader reads the volume folder with cloudFiles.format = "text", or csv if they're delimited, into a streaming table. You get incremental, exactly-once ingestion, and no file has to fit in one column.
Auto Loader can't read zips directly, which is why the unzip happens in step 1. There's also a Beta option to ingest SFTP files as the FILE type, which stores them as files instead of in a column. It's worth testing with your largest file.
4. Timeout settings I couldn't find any documented timeout settings for the SFTP connector or Auto Loader's fetch. If the quick test points to the download, open a support ticket with the connection name, file sizes and driver logs.
Docs: