Delta Lake
Synopsis
The Delta Lake target writes records to Delta Lake tables. A table can be on a local disk, in Amazon S3 or in Azure Blob Storage. Search, Spark, Microsoft Fabric and Databricks can read the tables that the target writes.
The target writes each record as a row of a Parquet data file, and adds the file to its table with a Delta commit. One target can write several tables, and a route chooses the table for each record.
The web interface has no card for the Delta Lake target. Configure it in a Director configuration file.
Schema
- name: <string>
description: <string>
type: deltalake
status: <boolean>
properties:
location: <string>
unity_catalog:
url: <string>
catalog: <string>
schema: <string>
token: <string>
client_id: <string>
client_secret: <string>
token_url: <string>
scope: <string>
table: <string>
schema: <string>
partition_by: <string[]>
compression: <string>
iceberg: <boolean>
tables:
- table: <string>
location: <string>
schema: <string>
retention: <string>
retention_column: <string>
compaction: <boolean>
partition_by: <string[]>
compression: <string>
iceberg: <boolean>
max_open_files: <numeric>
transaction_retention: <string>
retention: <string>
retention_column: <string>
maintenance_interval: <string>
compaction: <boolean>
batch_size: <numeric>
max_size: <numeric>
max_rows_per_rowgroup: <numeric>
timeout: <numeric>
interval: <numeric>
cron: <string>
field_format: <string>
key: <string>
secret: <string>
session: <string>
region: <string>
endpoint: <string>
use_path_style: <boolean>
connection_string: <string>
tenant_id: <string>
client_id: <string>
client_secret: <string>
account: <string>
debug:
status: <boolean>
dont_send_logs: <boolean>
Configuration
The following fields are used to define the target:
| Field | Required | Default | Description |
|---|---|---|---|
name | Y | Target name | |
description | N | - | Optional description |
type | Y | Must be deltalake | |
pipelines | N | - | Optional post-processor pipelines |
status | N | true | Enable/disable the target |
Tables
| Field | Required | Default | Description |
|---|---|---|---|
location | Y* | - | Where the tables are: a directory, s3://bucket/path or az://container/path. A relative directory starts at the Director's root directory. Each table is a directory below the location, named after the table |
table | N** | - | The table for every record whose route names no other table |
schema | Y | - | The table's columns: a Parquet schema from the Library, a JSON schema, or a column list such as TimeGenerated:datetime,Computer:string. See Columns |
partition_by | N | - | The columns that partition the table. Each must be a column of schema. See Partitions |
compression | N | snappy | The compression of the data files: snappy, zstd, gzip or none |
tables | N** | - | More tables. Each item sets table, and can set its own location, schema, partition_by and compression. A setting that an item leaves out comes from the target |
* = Required unless the target writes the tables of a Unity Catalog catalog (unity_catalog).
** = Set table, tables, or both. A target without a table doesn't start.
A table name can hold letters, digits, _, - and ..
Commits
| Field | Required | Default | Description |
|---|---|---|---|
batch_size | N | 100000 | A table's batch is committed early once it holds this many records |
max_size | N | 33554432 | A table's batch is committed early once its data files, and the records still held in memory, reach this many bytes (32 MB) |
max_open_files | N | 1024 | The most data files that one table's batch writes at once, one for each partition. A record for one partition more makes the target commit the batch first |
max_rows_per_rowgroup | N | 10000 | The rows of each row group in a data file |
timeout | N | 300 | How long one commit may take, in seconds, uploads of its data files included |
transaction_retention | N | 1h | How long a table that the target creates remembers each payload that it committed. See No Duplicates on Retry. 0 keeps the record for good |
field_format | N | - | Data normalization format. See applicable Normalization section |
Scheduling
The target commits what it has buffered once a minute. To commit on another schedule, set interval (seconds between commits) or cron. See Scheduling and Pool Behavior.
Amazon S3
The target signs in to S3 as the Amazon S3 target does.
| Field | Required | Default | Description |
|---|---|---|---|
key | N | - | AWS access key ID. Without key and secret, the target uses the AWS SDK's default credentials, such as the environment or an instance role |
secret | N | - | AWS secret access key |
session | N | - | Session token for temporary credentials |
region | N | - | AWS region of the bucket |
endpoint | N | - | The endpoint of an S3-compatible store |
use_path_style | N | false | Use path-style addressing. Set it for an endpoint without virtual-host DNS, such as MinIO or LocalStack |
Azure Blob Storage
The target signs in to Azure Blob Storage as the Azure Blob Storage target does: with a connection string, or with a service principal and the storage account.
| Field | Required | Default | Description |
|---|---|---|---|
connection_string | N* | - | Azure Storage connection string |
tenant_id | N* | - | Azure tenant ID of the service principal |
client_id | N* | - | Client ID of the service principal |
client_secret | N* | - | Client secret of the service principal |
account | N* | - | Storage account name |
* = Set connection_string, or the service principal and the account.
Debug Options
| Field | Required | Default | Description |
|---|---|---|---|
debug.status | N | false | Enable debug logging |
debug.dont_send_logs | N | false | Process logs but don't write them to the tables (testing) |
Details
Where Tables Live
location names where the tables are, and each table is a directory below it, named after the table. For example, with location: s3://my-bucket/lake, the table events is in s3://my-bucket/lake/events.
- A local directory: a path such as
/var/lib/lakeorlake. A relative path starts at the Director's root directory. - Amazon S3:
s3://bucket/path. The bucket can also be in an S3-compatible store. - Azure Blob Storage:
az://container/path. The container must exist before the target starts.
A table under tables can set its own location, so one target can write tables in more than one place.
The target reads each table when it starts. If it can't reach the storage, or a table can't take its records, the target doesn't start, and its error names the table.
Tables and Routing
table is the catch-all table. It takes every record whose route names no other table, or names a table that the target doesn't have.
tables lists more tables. A route sends a record to one of them when it sets _vmetric.table to the table's name. Without a catch-all table, a record for a table that the target doesn't have is refused.
The target creates a table that doesn't exist yet, with the columns of schema and the partitions of partition_by.
Columns
schema gives a table its columns. It takes one of these:
- The name of a Parquet schema in the Library.
- A JSON schema, as described on the Parquet page.
- A column list, such as
TimeGenerated:datetime,Computer:string,EventID:int.
The columns can be STRING, BOOLEAN, DOUBLE, FLOAT, INT32, INT64 or DATETIME. A partition column can also be a DATE. The target refuses a list, a group or a dotted column name.
Each record is a JSON object, and its fields fill the columns of the same name. A record that is JSON but not an object, such as an array, is refused. A field that the schema doesn't list is not written.
VARIANT Columns
A column can also be a VARIANT. A VARIANT column holds semi-structured data, such as a JSON object, in a binary form that queries can read field by field.
- In a Parquet schema, a field of type
VARIANTbecomes a VARIANT column. It must be optional: the target refuses a required VARIANT field. - In a column list, a
dynamiccolumn becomes a VARIANT column, as inTimeGenerated:datetime,Properties:dynamic.
The target shreds a VARIANT column when the table allows it: the data files also store the fields that most documents have in columns of their own, so a query that reads one of those fields reads only that column. A table that the target creates with a VARIANT column allows shredding. Where a table doesn't allow it, the target writes the column unshredded. See VARIANT Columns in Delta Tables on the Search page for the readers that can open each kind of table.
A VARIANT column can't partition a table.
Partitions
partition_by names the columns that partition a table. A partition column can be STRING, BOOLEAN, INT32, INT64, DATE or DATETIME. A table needs at least one column that doesn't partition it.
Choose partition columns with few values, such as a day or a region. A partition is one combination of the partition columns' values. Each commit writes a data file of its own for every partition that it has records for. A column with many values, such as a host name, makes many small files.
max_open_files limits how many data files one batch writes at once. When a record would open one more, the target commits the batch first.
A partition column's values are kept in the table's log and in the names of the files' directories, not in the data files.
Iceberg Metadata
With iceberg: true, each table that the target creates also carries Apache Iceberg metadata, as Delta's UniForm writes it. Readers of Iceberg tables then read the table's data files in place, so the data is stored once. Set it for the whole target, or for one table under tables.
| Field | Required | Default | Description |
|---|---|---|---|
iceberg | N | false | true makes each table that the target creates also an Iceberg table. Each item of tables can set its own |
targets:
- name: lake
type: deltalake
properties:
location: "s3://my-bucket/lake"
region: "us-east-1"
table: events
schema: "TimeGenerated:datetime,Computer:string,Day:date"
partition_by: [Day]
iceberg: true
tables:
- table: audit
iceberg: false
- New tables only. The setting applies to the tables that the target creates. A table that was there already keeps its properties: the target logs a warning once and writes no Iceberg metadata for it. To turn the metadata on for such a table, run Search's
ALTER TABLE ... SET TBLPROPERTIES ('delta.universalFormat.enabledFormats' = 'iceberg')on it. See Iceberg Metadata for Delta Tables on the Search page. - Tables made UniForm elsewhere. A table that another writer made a UniForm table gets its Iceberg metadata whatever the setting says.
- When it is written. The target writes the metadata after each commit, without making the commit wait. If writing it fails, the commit still stands: the target logs a warning, and the table's next commit or its next maintenance writes what is missing.
- What changes in the table. Such a table maps its columns by name and tracks its rows' IDs. Each data file also holds the values of the table's partition columns. Readers of the table as a Delta table must support column mapping by name.
- Maintenance. The target's scheduled
VACUUMalso brings the metadata up to date and expires its old snapshots. - Azure Blob Storage. The metadata names the files by
abfss://<container>@<account>.dfs.core.windows.net/...URLs. - Unity Catalog. A table of a Unity Catalog catalog can't set
iceberg: the target refuses to start. Turn on UniForm in the catalog instead.
Commits
The target buffers records for each table, and commits them once a minute, or on the schedule that interval or cron sets. A table's batch is also committed early when it reaches batch_size records or max_size bytes.
Each commit adds a data file for each partition that it wrote, and a new version of the table. Readers see the rows once the commit lands.
When a commit fails, the target sends the batch's records again. Other tables of the same target are still committed.
No Duplicates on Retry
A payload that the Director sends again doesn't add its rows twice. Each commit records which payloads it holds. When a payload comes back, the target leaves out the records that the table already holds.
A table that the target creates keeps this record for transaction_retention, one hour by default. The hour counts while the table is written to: a pause in its commits, such as a Director that was down for a day, counts 10 minutes at most. A payload that keeps coming back has its record renewed, for up to the Director's persistent_storage.max_age (48 hours by default).
Keep transaction_retention short. The table's log, each of its checkpoints and the Director's memory hold about one record for each payload of that period.
Another engine that writes a checkpoint of the table, such as Spark with OPTIMIZE, counts the time by the clock. If the Director is down for longer than transaction_retention while such an engine writes a checkpoint, a payload that comes back after that can add its rows twice.
A table that the target creates also writes a checkpoint every 100 commits (delta.checkpointInterval) and keeps its log for 2 days (delta.logRetentionDuration). A table that was there before keeps its own properties. To give it the same behaviour, set delta.setTransactionRetentionDuration, delta.checkpointInterval and delta.logRetentionDuration on it with ALTER TABLE ... SET TBLPROPERTIES. If such a table has no delta.setTransactionRetentionDuration, the target logs a warning, because the table then keeps the record of every payload.
Table Maintenance
The target maintains the tables it writes, on a schedule. Maintenance is on by default and runs every hour, so nobody has to run OPTIMIZE or VACUUM by hand.
A target that was set up before maintenance existed starts maintaining its tables every hour as soon as the Director is upgraded. It merges small data files, and deletes data files and log files that the tables no longer need, by each table's own Delta retention settings. It removes rows only when retention is set. To keep the old behaviour, set maintenance_interval: 0.
| Field | Required | Default | Description |
|---|---|---|---|
retention | N | - | How long a table keeps its rows, such as 30d, 2w or 12h. Empty or 0 keeps every row. A value under one hour is refused, because 30m means 30 minutes, not 30 months. Each item of tables can set its own |
retention_column | N | see below | The DATE or DATETIME column that says how old a row is. Each item of tables can set its own |
maintenance_interval | N | 1h | How often maintenance runs, such as 1h or 1d. It must be at least one minute. 0 turns maintenance off |
compaction | N | true | Merges the small data files of each partition during maintenance. false turns it off for the target's tables, or, set on an item of tables, for that table |
Without retention_column, the target takes the table's first DATE or DATETIME partition column. If there is none, it takes the table's only DATE or DATETIME column. If the table has several such columns and none partitions it, set retention_column: the target doesn't start until it knows which one to use.
The target checks these settings when it starts. A wrong value stops the target with an error that says what to fix. retention together with maintenance_interval: 0 is refused, because nothing would then remove the old rows.