Before you start
Prepare an existing Delta table and storage access for the engine and workers. Use a private external table withorder_id BIGINT and amount DOUBLE for the write examples. Its protocol must use minReaderVersion = 1 and minWriterVersion = 2. The sink requires a table that already has a valid Delta log. An empty directory is not a Delta table.
To use SQL mutations, the existing table must also be available through a catalog that exposes the required Delta write capabilities. The examples use demo.examples.delta_orders. Replace this name with the qualified name of your private table.
Catalog credentials and data-file credentials can differ. See Data access and the guide for your catalog service.
Read a table by path
Replace the path with the Delta table root, which contains its transaction log. Use this root rather than a folder of individual Parquet files.Read a historical version
Use a version that still exists in the table history:spark connection described in Read and write files.
timestampAsOf with an RFC 3339 timestamp that includes a timezone. Choose a version or timestamp, not both. Retention can make an older snapshot unavailable.
Append and overwrite
The following client example requires an existing empty external table with the sample schema. It first appends two rows. It then overwrites the table with one row.(1, 12.5) after overwrite. A new submission of a completed append adds rows again. Whole-table overwrite removes the old active rows from the new snapshot.
Catalog tables also accept INSERT INTO and INSERT OVERWRITE TABLE when their catalog exposes the required commit operation.
Update, delete, and merge
These statements use the same private catalog table after the client example. Its catalog name must resolve to the same table root.(1, 16.0). Row mutations use a full target read and rewrite the affected table data through the coordinated write path. They are subject to the table protocol and catalog capabilities.
Options
Use Delta source limits for metadata, scan, and object-count budgets. File parsing settings such as
header and inferSchema do not apply to Delta tables.