Static mode wipes the table
Run a one-day refresh and watch prior partitions disappear under the documented default.
See the example →INSERT OVERWRITE defaults to static mode: without a PARTITION clause it truncates all table data — not just the partitions your source touches. The legacy dynamic-mode escape hatch is not supported on SQL warehouses or serverless. The compute-independent fix is REPLACE USING — key-equality, atomic, safe on empty sources.
A practical runbook for partition-scoped replacements that must behave the same on clusters, SQL warehouses, and serverless.
Run a one-day refresh and watch prior partitions disappear under the documented default.
See the example →Compare REPLACE WHERE, REPLACE USING, REPLACE ON, and the legacy dynamic-mode setting.
Choose safely →The cluster-only session setting vanished at migration time. Replace it with one compute-independent statement.
Get the answer →Last verified against official Databricks docs: September 30, 2026. Correction history: Sep 30, 2026 — added the missing staging_daily setup with before/after results; replaced undocumented “silently ignored” with “not supported”; qualified wipe claims with the no-PARTITION-clause condition.
CREATE OR REPLACE TABLE main.default.daily_sales (
sale_id INT, dt DATE, amount DECIMAL(10,2)
) PARTITIONED BY (dt);
INSERT INTO main.default.daily_sales VALUES
(1, DATE '2026-09-28', 120.00),
(2, DATE '2026-09-29', 85.50),
(3, DATE '2026-09-29', 41.00);
CREATE OR REPLACE TEMP VIEW staging_daily AS
SELECT 4 AS sale_id,
DATE '2026-09-30' AS dt,
CAST(99.00 AS DECIMAL(10,2)) AS amount;
SELECT sale_id, dt, amount
FROM main.default.daily_sales
ORDER BY dt, sale_id;
INSERT OVERWRITE TABLE main.default.daily_sales
SELECT * FROM staging_daily WHERE dt = DATE '2026-09-30';
SELECT sale_id, dt, amount
FROM main.default.daily_sales
ORDER BY dt, sale_id;
INSERT INTO main.default.daily_sales
REPLACE USING (dt)
SELECT * FROM staging_daily;
This replaces only rows whose dt matches a dt present in the source, leaves every other row untouched, inserts rows with new keys, and — unlike REPLACE WHERE — deletes nothing when the source is empty. On DBR 16.3–17.1 the USING list must contain the full set of the table's partition columns; on 17.2+ any columns work, on partitioned, unpartitioned, or liquid-clustered tables.
SELECT DISTINCT dt FROM staging_daily — confirm they are the partitions you intend to touch.SET spark.sql.sources.partitionOverwriteMode job — in SQL it is classic-compute-only and not supported elsewhere.Read the selective-overwrite contract, then practice production data-engineering patterns.
Official docs: Selectively overwrite data with Delta Lake
Practice path: Browse DataCamp data engineering →
Partner links: we may earn a commission if you enroll through these recommendations, at no extra cost to you.