Home / Databricks on Azure

Databricks on AzureCheat sheetAdvanced

Delta table properties cheat sheet for Azure Databricks: retention, file sizing, statistics and table features

The delta.* table properties that change retention, file sizes, data skipping and table features. How to read, set and audit them, and which ones you can't undo.

Deepak Bhardwaj7 min read

Applies toAzure Databricks, Databricks Runtime 13.3 LTS and later (some properties need newer runtimes), Delta tables in Unity Catalog and the Hive metastore

When you need this

Many Delta problems come down to a table property somebody set months ago, or never set. Examples include time travel failing after 7 days, VACUUM deleting files a stream still needs, an external reader breaking after deletion vectors were turned on, or a filter that skips nothing because the column has no statistics. This page lists the properties that matter in operations, how to inspect them and which changes are one-way.

Property names below use the delta. prefix. Defaults come from the Azure Databricks table properties reference. Some defaults depend on runtime version and workspace settings, so confirm on your build.

Read and change properties

-- All properties on one table
SHOW TBLPROPERTIES main.sales.orders;

-- One property
SHOW TBLPROPERTIES main.sales.orders ('delta.logRetentionDuration');

-- Properties plus protocol versions and table features
DESCRIBE DETAIL main.sales.orders;

-- Set, then remove (falls back to the default)
ALTER TABLE main.sales.orders SET TBLPROPERTIES ('delta.logRetentionDuration' = 'interval 60 days');
ALTER TABLE main.sales.orders UNSET TBLPROPERTIES ('delta.logRetentionDuration');

-- Who changed a property, and when
SELECT version, timestamp, userName, operation, operationParameters
FROM (DESCRIBE HISTORY main.sales.orders)
WHERE operation IN ('SET TBLPROPERTIES', 'UNSET TBLPROPERTIES');

Warning

SET TBLPROPERTIES is a commit to the table, and it can conflict with concurrent writes. Change properties when streams and jobs writing to the table are paused, or expect one of the writers to fail and retry.

Retention: history, VACUUM and streaming idempotency

Property Default What it controls
delta.logRetentionDuration interval 30 days How long transaction log history is kept, which limits how far back time travel can go
delta.deletedFileRetentionDuration interval 1 week How long VACUUM keeps removed data files. Also limits time travel
delta.setTransactionRetentionDuration not set How long transaction identifiers (txnAppId/txnVersion, used for idempotent foreachBatch writes) are kept

Time travel to a version needs both its log entry and its data files. If you want 30 days of restore capability, raise deletedFileRetentionDuration to match. Raising logRetentionDuration alone isn't enough.

ALTER TABLE main.sales.orders SET TBLPROPERTIES (
  'delta.logRetentionDuration' = 'interval 30 days',
  'delta.deletedFileRetentionDuration' = 'interval 30 days'
);

Caution

Running VACUUM with a retention shorter than 7 days requires turning off spark.databricks.delta.retentionDurationCheck.enabled. That can delete files that running queries, streams and clones still read, and it removes time travel to those versions permanently.

Longer file retention means more storage. Check the table's size in DESCRIBE DETAIL before you set months-long values on large tables.

File sizing and compaction

Property Default Use
delta.autoOptimize.optimizeWrite not set Shuffles data before writing so each write produces fewer, larger files
delta.autoOptimize.autoCompact not set Accepts auto, true, legacy or false. Compacts small files after a write
delta.targetFileSize not set Target file size for OPTIMIZE and tuning, for example '128mb' or 104857600
delta.tuneFileSizesForRewrites auto-detected Smaller files for tables with frequent MERGE, UPDATE and DELETE
ALTER TABLE main.iot.events SET TBLPROPERTIES (
  'delta.autoOptimize.optimizeWrite' = 'true',
  'delta.autoOptimize.autoCompact' = 'auto'
);

On Unity Catalog managed tables with predictive optimization turned on, Databricks schedules OPTIMIZE and VACUUM for you. Set file sizing properties only when you have measured a problem, such as small files from a stream.

Statistics and data skipping

Property Default Use
delta.dataSkippingNumIndexedCols 32 Collect min/max statistics on the first N columns. -1 means all columns
delta.dataSkippingStatsColumns not set Comma-separated list of columns to collect stats on. Takes precedence over dataSkippingNumIndexedCols

Use the explicit list for wide tables where the filter columns sit past position 32:

ALTER TABLE main.sales.orders SET TBLPROPERTIES (
  'delta.dataSkippingStatsColumns' = 'order_date,customer_id,region'
);

-- Changing the list only affects new files. Recompute stats for existing files:
ANALYZE TABLE main.sales.orders COMPUTE DELTA STATISTICS;

Collecting statistics on long string columns slows writes and adds little skipping value. Keep them out of the list.

Table features: check before you enable

Enabling these properties upgrades the table protocol. Readers and writers that don't support the feature then fail, including older runtimes, Synapse serverless SQL, some Power BI connectors and older open-source Spark.

Property Default Protocol (reader/writer) Notes
delta.enableChangeDataFeed false 1/4 Records row-level changes for incremental downstream reads
delta.enableDeletionVectors depends on workspace and runtime 3/7 Faster DELETE, UPDATE and MERGE. Common cause of external reader failures
delta.columnMapping.mode none 2/5 name or id. Allows column rename and drop
delta.enableRowTracking false 1/7 Needed by some incremental features, such as materialized view refresh
delta.enableTypeWidening false 3/7 Widen types such as INT to BIGINT without rewriting data
delta.checkpointPolicy classic v2 enables V2 checkpoints
delta.universalFormat.enabledFormats not set iceberg lets Iceberg clients read the table (UniForm)

Caution

Most protocol upgrades can't be undone. Setting a feature property back to false doesn't downgrade the protocol. Never set delta.minReaderVersion or delta.minWriterVersion by hand. Before you enable a feature on a table that is shared with other engines, test their read path against a clone.

If you have to remove a feature, recent runtimes support dropping supported features. This rewrites data and history, so plan a maintenance window and check that your runtime supports it:

ALTER TABLE main.sales.orders DROP FEATURE deletionVectors;

Write behaviour

Property Default Use
delta.appendOnly false true blocks UPDATE and DELETE, which is useful for audit and raw landing tables
delta.isolationLevel WriteSerializable Serializable is stricter and causes more concurrent write conflicts
delta.parquet.compression.codec ZSTD Runtime 16.0 and later. Also SNAPPY, GZIP, LZ4, BROTLI
delta.randomizeFilePrefixes false Spreads file names over random prefixes for very high request rates

Defaults for new tables

Set session defaults with spark.databricks.delta.properties.defaults.<name>, where <name> is the property name without the delta. prefix. They apply only to tables created in that session, not to existing tables.

SET spark.databricks.delta.properties.defaults.enableChangeDataFeed = true;
SET spark.databricks.delta.properties.defaults.deletedFileRetentionDuration = 'interval 14 days';

To make defaults apply everywhere, put them in a compute policy or the job's Spark config rather than relying on each notebook.

Audit properties across a schema

props = ["delta.logRetentionDuration", "delta.deletedFileRetentionDuration",
         "delta.enableDeletionVectors", "delta.enableChangeDataFeed",
         "delta.columnMapping.mode", "delta.appendOnly"]

tables = spark.sql("""
  SELECT table_catalog, table_schema, table_name
  FROM main.information_schema.tables
  WHERE table_schema = 'sales' AND data_source_format = 'DELTA'
""").collect()

rows = []
for t in tables:
    fqn = f"`{t.table_catalog}`.`{t.table_schema}`.`{t.table_name}`"
    p = {r.key: r.value for r in spark.sql(f"SHOW TBLPROPERTIES {fqn}").collect()}
    rows.append((fqn, *[p.get(k, "(default)") for k in props]))

display(spark.createDataFrame(rows, ["table"] + props))

Run it before and after a change window, and keep the output as evidence of what was set.

Prevent surprises next time

  • Decide retention per table tier (for example raw 7 days, silver and gold 30 days) and set both retention properties together.
  • Treat table feature properties as a change request. Check every reader of the table first.
  • Set properties in the code that creates the table (TBLPROPERTIES in CREATE TABLE, Lakeflow table definitions, or bundles) so that a recreate doesn't silently reset them.
  • Review DESCRIBE HISTORY for SET TBLPROPERTIES operations when a table's behaviour changes unexpectedly.