yggdrasil.databricks.table.auto_loader¶
auto_loader ¶
On-cluster Auto Loader (cloudFiles) ingestion entry point.
:func:auto_load is what the Databricks job built by
:meth:yggdrasil.databricks.table.table.Table.auto_loader actually runs on
the cluster, invoked by the ygg databricks table autoload CLI subcommand
(from the shipped ygg wheel). It streams files from a source path into a Unity
Catalog table via Spark Structured Streaming + Databricks Auto Loader —
incremental, exactly-once, schema-evolving — so a table keeps absorbing new
files dropped at source without a bespoke pipeline.
Kept as a plain module-level function (typed params) so the ygg databricks
table autoload handler stays thin: it just coerces its CLI args and calls in
here.
auto_load ¶
auto_load(
table: str,
source: str,
file_format: str = "parquet",
checkpoint: str = "",
available_now: bool = True,
clean_source: bool = False,
clean_source_retention: str = "8 days",
) -> dict[str, Any]
Ingest files under source into table with Databricks Auto Loader.
Each micro-batch is cast to the target table's schema before the append
(yggdrasil's Schema.cast_spark_tabular — the same field casting
arrow_insert / spark_insert use): columns are name-matched, missing
ones NULL-filled, and types — including nested array<struct> and
timestamp zones — cast to the target. The cast runs on every micro-batch as
the stream flows, so the write stays schema-stable and tolerant of source
drift (extra columns dropped, mismatches cast) rather than failing the stream
or evolving the target schema; .toTable keeps Structured Streaming's
built-in, checkpoint-coordinated exactly-once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Target table, |
required |
source
|
str
|
Cloud path Auto Loader watches ( |
required |
file_format
|
str
|
|
'parquet'
|
checkpoint
|
str
|
Streaming checkpoint + schema location. Empty → derived as
|
''
|
available_now
|
bool
|
|
True
|
clean_source
|
bool
|
|
False
|
clean_source_retention
|
str
|
Retention window for clean_source
( |
'8 days'
|
Returns a small summary dict (table + resolved checkpoint + rows ingested when known) — handy in the job run output / when called locally.