Does Databricks handle table maintenance automatically?
Yes. Predictive Optimization runs OPTIMIZE, VACUUM, and ANALYZE on Unity Catalog managed tables based on usage, so you do not have to schedule those jobs. It is enabled by default for accounts created on or after November 11, 2024, and Databricks has been enabling it for existing accounts. You can check the status for a table, catalog, or schema with DESCRIBE ... EXTENDED.
Do I have to manually tune and optimize tables on Databricks?
No. Predictive Optimization automatically runs OPTIMIZE, VACUUM, and ANALYZE on Unity Catalog managed tables, including Delta Lake and Iceberg formats, and keeps the statistics used by the cost-based optimizer up to date. It is enabled by default for accounts created on or after November 11, 2024. The cited page says rollout to existing accounts is expected to complete by August 2026 but does not confirm current status, so check your account's feature enablement setting. It does not run on external tables, so those still need your own maintenance plan.
Can Predictive Optimization automatically maintain Iceberg tables?
Yes. Predictive Optimization automatically runs OPTIMIZE, VACUUM, and ANALYZE on Unity Catalog managed tables, which include Iceberg tables. On tables with Iceberg reads enabled, VACUUM metadata cleanup requires Databricks Runtime 17.2 or above, and Predictive Optimization automates it. This removes manual maintenance for those tables.
How do you enforce unique keys or unique column constraints in Databricks?
Databricks enforces NOT NULL and CHECK constraints on Delta tables, and a write that violates either one fails the transaction with an error. Primary key, foreign key, and unique constraints are informational only and are not enforced, but they document table relationships and can help query optimization. To keep keys unique in practice, deduplicate incoming data and use MERGE to upsert on the business key, since MERGE requires that only a single source row matches each target row. From Databricks Runtime 16.0, MERGE also evaluates WHEN MATCHED conditions, in addition to ON, when it detects duplicate matches.
What is the correct way to consume and transform Delta table changes in Databricks?
Change data feed records row-level changes between table versions, with _change_type values of insert, update_preimage, update_postimage, and delete, plus _commit_version and _commit_timestamp metadata. The recommended pattern is Structured Streaming, which tracks versions for you: set readChangeFeed to true on spark.readStream and use a checkpoint location. Automatic change data feed needs no per-table setting, computes changes at query time, and requires Databricks Runtime 19 or above on a Unity Catalog table. For a permanent audit history, write the changes to another table, because change feed records expire after a retention window, and use the AUTO CDC APIs for SCD Type 1 or Type 2 processing.
What is the best way to change an existing Delta table schema?
Use ALTER TABLE to change the schema in place: ADD COLUMNS (with optional COMMENT and FIRST or AFTER positioning), ALTER COLUMN for comments or position, and REPLACE COLUMNS to redefine the full column list. Renaming and dropping columns require Delta Lake column mapping; with column mapping enabled, RENAME COLUMN and DROP COLUMN are metadata-only operations that don't rewrite data files, though dropped data stays in the files until REORG TABLE and VACUUM remove it. Type widening is also a supported schema change. For other column type changes, rewrite the table with mode('overwrite') and overwriteSchema set to true. For schema changes that arrive with the data, use WITH SCHEMA EVOLUTION on INSERT or MERGE, or the mergeSchema option on batch and streaming writes.
What is the best approach to data versioning at scale in Databricks?
Delta Lake time travel lets you query earlier versions of a table, which is useful for recreating past outputs, fixing data mistakes, and providing snapshot isolation. Every write creates a new table version, and DESCRIBE HISTORY lists the operation, user, and timestamp for each one. A version stays queryable only while both its log and data files are retained: table history defaults to 30 days through delta.logRetentionDuration, and data files become eligible for VACUUM after delta.deletedFileRetentionDuration, which defaults to 7 days. Table history is not a long-term backup or archive, and raising retention settings increases storage cost.
How does Delta Lake keep data consistent when multiple writers update a table?
Delta Lake provides ACID transactions, and multiple writers across multiple clusters can modify the same table partition at once, with writes ordered serially so that each writer sees a consistent snapshot. Readers keep the consistent snapshot their job started with, even if the table changes during the job. Writes that conflict, such as a ConcurrentAppendException, fail with a conflict exception. Isolation levels, WriteSerializable and Serializable, control how concurrent operations interact and are set with the delta.isolationLevel table property, and row-level conflict detection reduces conflicts on the same data files.
How does a query on a Delta table skip irrelevant data?
Delta Lake collects data skipping statistics for each file, including minimum and maximum values, null counts, and total record counts, automatically when it writes to a Delta Lake or managed Apache Iceberg table. At query time, Databricks uses these statistics to skip files that cannot match the query predicates, so less data is read. By default, statistics are collected on the first 32 columns of a Unity Catalog external table, and for Unity Catalog managed tables predictive optimization can also collect them on frequently filtered columns beyond the first 32. You can choose the statistics columns with delta.dataSkippingStatsColumns, and Databricks recommends liquid clustering for the table layout that file skipping depends on.
Medium articles say you cannot partition a Delta table by a generated column, so the partition value has to be computed in the pipeline?
Delta Lake generated columns compute and store values from a user-defined expression, and they can be used as partition columns. For example, eventDate defined as CAST(eventTime AS DATE) can appear in PARTITIONED BY (eventType, eventDate), and Delta derives partition filters automatically when you filter on the base column. The docs mark this feature as Public Preview.
What does Delta schema enforcement do when a write does not match the table schema?
Schema enforcement rejects writes that do not match the table schema on Delta tables, so mismatched data does not land silently. An INSERT must reference only columns that exist in the target, and column types must match, with Databricks casting safely where possible, such as an integer written into a BIGINT column. With INSERT * or UPDATE SET * in a MERGE, the source must contain every target column. Enforcement applies to Delta tables, not to CSV or JSON files in cloud storage, and it checks writes against the existing schema, whereas schema evolution changes the schema.
How do I read the changes recorded by change data feed between two versions?
Use the table_changes function, for example SELECT * FROM table_changes('<table_name>', 0), which reads from version 0 to the latest version. Start and end versions are inclusive, and you can omit the end version to read through the latest. In Python and Scala batch reads, use readChangeFeed with startingVersion, endingVersion, startingTimestamp, and endingTimestamp options, where timestamps use the yyyy-MM-dd[ HH:mm:ss[.SSS]] format. Requesting a version from before change data feed was enabled raises an error.
What does DESCRIBE HISTORY return for a Delta table?
DESCRIBE HISTORY returns information for each write to the table, including the operation, the user, and the timestamp, listed in reverse chronological order. History is kept for delta.logRetentionDuration, which defaults to 30 days, and that retention determines how far back the history goes. Use DESCRIBE HISTORY to audit writes or to find the version you want to query with time travel.
What does a shallow clone of a Delta table copy?
A shallow clone copies only the metadata, not the data files, so it is cheaper to create because it uses less compute and storage. It copies the schema, partitioning, invariants, nullability, and TBLPROPERTIES, and its readers need access to the source table's data files. On legacy Hive metastore tables, running VACUUM on the source can break shallow clones that still reference its files.
Which Delta table features can be dropped with ALTER TABLE ... DROP FEATURE?
ALTER TABLE <table> DROP FEATURE <feature> can drop catalogManaged, checkConstraints, collations-preview, columnMapping, deletionVectors, typeWidening, v2Checkpoint, and checkpointProtection, one feature per command. Other Delta Lake table features cannot be dropped. You need MODIFY privilege on the table, and Databricks recommends Databricks Runtime 16.3 or above for all DROP FEATURE commands.
What does TRUNCATE HISTORY do when fully downgrading a Delta table for legacy clients?
For a full downgrade so that legacy external Delta clients can keep working, use TRUNCATE HISTORY. It runs in two steps at least 24 hours apart: the first turns off the feature, resets its properties, and rewrites files, and the second truncates history to the retention threshold, confirms no transactions use the feature, drops it, and downgrades the protocol. The command removes transaction log data older than 24 hours, so after a full downgrade you can no longer access table history or use time travel.
What isolation level do Delta tables use by default, and how do I change it?
Delta tables default to WriteSerializable, which Databricks recommends keeping for most workloads. Reads always use snapshot isolation under both levels. Under WriteSerializable, a DELETE, UPDATE, or MERGE can commit after a concurrent insert, so table contents may not match a replay of the history order. Serializable makes a later conflicting operation fail so it must be retried, at a cost to concurrent write throughput. Set it with ALTER TABLE <table-name> SET TBLPROPERTIES ('delta.isolationLevel' = 'Serializable'), and set it back to WriteSerializable to restore the default.
Which type changes does Delta type widening support, and what runtime do I need?
Delta type widening lets a column move to a wider compatible type, such as BYTE to SHORT, INT, BIGINT, DECIMAL or DOUBLE, INT to BIGINT, DECIMAL or DOUBLE, and DATE to TIMESTAMP_NTZ. It covers top-level columns and nested struct, map and array fields. It requires Databricks Runtime 15.4 LTS or above, and streaming support requires Runtime 16.4 LTS or above. Enable it with ALTER TABLE ... SET TBLPROPERTIES ('delta.enableTypeWidening' = 'true').
If I want out, can I just export my Databricks tables to plain Parquet or CSV?
Yes, table contents can be exported. INSERT OVERWRITE DIRECTORY writes query results to a directory using a specified Spark file format, including TEXT, CSV, JSON, PARQUET, and ORC. That moves the data but not the catalog entries, grants, or the pipelines that maintain the tables, which you must rebuild elsewhere. Pair the export with an inventory of tables, grants, and jobs so the handover is complete.
Auto-compaction and liquid clustering make engineers less technical. Isn't that a crutch?
Automation removes routine tuning, and you keep control of what matters. Predictive optimization automatically runs OPTIMIZE, VACUUM and ANALYZE on Unity Catalog managed tables, Databricks recommends it for all Unity Catalog managed tables, and it is enabled by default for accounts created on or after November 11, 2024. Automatic liquid clustering can choose clustering keys from your data usage patterns. Retention is still a design decision: VACUUM's deleted-file retention defaults to 7 days, and shorter retention limits time travel, so set it deliberately before relying on automation.