> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delta Lake

> Read Delta snapshots and write to supported existing external tables.

How-to guide

The Delta connector reads a Delta table's transaction log and data files. It supports current and historical snapshots. Writes support append, whole-table overwrite, update, delete, and merge for supported existing external tables.

## Before you start

Prepare an existing Delta table and storage access for the engine and workers. Use a private external table with `order_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](https://docs.e6data.com/transformation/concepts/data-access.md) and the guide for your [catalog service](https://docs.e6data.com/transformation/recipes/overview.md).

## 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.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT order_id, amount
FROM delta.`<delta-table-root>`
ORDER BY order_id;
```

For a catalog table, use its qualified name:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT order_id, amount
FROM demo.examples.delta_orders
ORDER BY order_id;
```

The reader applies the selected snapshot's active data and supported delete metadata. A plain Parquet scan of the table directory does not provide Delta table semantics.

## Read a historical version

Use a version that still exists in the table history:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT order_id, amount
FROM delta.`<delta-table-root>` VERSION AS OF 0
ORDER BY order_id;
```

The Spark Connect client also accepts version or timestamp selection. Use the `spark` connection described in [Read and write files](https://docs.e6data.com/transformation/connectors/files.md#connect-a-python-client).

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
table_path = "<existing-delta-table-root>"
historical = (
    spark.read.format("delta")
    .option("versionAsOf", "0")
    .load(table_path)
)
historical.show()
```

For timestamp selection, use `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.

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
table_path = "<existing-private-delta-table-root>"
orders = spark.createDataFrame(
    [(1, 12.5), (2, 7.5)], "order_id BIGINT, amount DOUBLE"
)

orders.write.format("delta").mode("append").save(table_path)
assert spark.read.format("delta").load(table_path).count() == 2

orders.where("order_id = 1").write.format("delta").mode("overwrite").save(table_path)
written = spark.read.format("delta").load(table_path)
written.show()
assert written.count() == 1
```

Expect `(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.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
UPDATE demo.examples.delta_orders
SET amount = 15.0
WHERE order_id = 1;

MERGE INTO demo.examples.delta_orders AS target
USING (VALUES (1, 16.0), (2, 7.5)) AS source(order_id, amount)
ON target.order_id = source.order_id
WHEN MATCHED THEN UPDATE SET amount = source.amount
WHEN NOT MATCHED THEN INSERT (order_id, amount)
VALUES (source.order_id, source.amount);

DELETE FROM demo.examples.delta_orders WHERE order_id = 2;

SELECT order_id, amount FROM demo.examples.delta_orders ORDER BY order_id;
```

Expect one row, `(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

| Option or setting | Default | Meaning |
| - | - | - |
| `path` or `load(path)` | Required for a direct read | Existing Delta table root. |
| `versionAsOf` | Current snapshot | Non-negative table version for a direct client read. SQL uses `VERSION AS OF`. |
| `timestampAsOf` | Unset | RFC 3339 timestamp with a timezone for a historical client read. |
| Client write mode | Explicit in these examples | `append` or whole-table `overwrite`. |
| Custom sink options | None | The Delta sink does not accept custom write options. |

Use [Delta source limits](https://docs.e6data.com/transformation/reference/configuration/delta-source-limits.md) for metadata, scan, and object-count budgets. File parsing settings such as `header` and `inferSchema` do not apply to Delta tables.

## Data types and limits

The Delta log defines field types, partitions, and the active table version. The reader and writer validate protocol features and schema support. Support for one Delta table does not imply support for every table produced by another platform.

Writes require an existing external table. Managed Delta publication, creating a table through this sink, writer schema evolution, and arbitrary sink options are not supported. Tables marked append-only reject overwrite and row mutations. Catalogs can impose further write limits.

The writer currently accepts protocol reader version 1 and writer version 2 only. It rejects table constraints and field metadata used for mapped, generated, or constrained columns. Reads and writes can therefore support different sets of Delta features. Basic nested structs, lists, and maps are checked recursively; required fields must not receive null values.

A SQL script is a sequence of separate operations. Check the new table state after each confirmed write. Do not reuse the mutation examples on a shared production table.

## Cleanup

Keep an existing shared table in place. If you prepared a private copy for this guide, remove that copy through its catalog and storage tools after the examples finish. Disconnecting a client does not delete table data.

## Related guides

* [Connector support matrix](https://docs.e6data.com/transformation/connectors.md)
* [Data access](https://docs.e6data.com/transformation/concepts/data-access.md)
* [SQL writes](https://docs.e6data.com/transformation/sql/writes.md)
* [Unity Catalog connection](https://docs.e6data.com/transformation/connect/catalogs/unity-native.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.