0

I have an external Delta table in Databricks with data files stored in an S3 backend. I want to completely remove(drop) this external Delta table, including all data files and Delta log files from the S3 location, using Databricks SQL commands (not Python).

I tried deleting the data with DELETE FROM TABLE_NAME, then dropped the external Delta table, and finally ran VACUUM with RETAIN 0 HOURS. This successfully removed all data files from S3, but the Delta log files remain. How can I remove Delta log files using SQL commands?

%sql
CREATE TABLE dev_catal_nm.dbx.table_name1(
  id INT,
  name STRING  -- VARCHAR(25) is equivalent to STRING in Databricks SQL
)
USING DELTA
LOCATION 's3://my_bucket_test/poc/table_name1';

%sql
INSERT INTO  dev_catal_nm.dbx.table_name1
VALUES (1, 'John');

%sql
SET spark.databricks.delta.retentionDurationCheck.enabled = false;

%sql
DROP TABLE IF EXISTS  dev_catal_nm.dbx.table_name1;

%sql
VACUUM 's3://my_bucket_test/poc/table_name1' RETAIN 0 HOURS;

But log file still exists. I want to drop delta log file
1
  • You are doing right thing. As per docs.databricks.com/en/sql/language-manual/… all files should be deleted, unless you requested to create external table. Can you double check you never called CREATE EXTERNAL for this location? Can you try you commands for new location which was not (presumably) used before as external? Commented Sep 6, 2024 at 15:26

1 Answer 1

0
dbutils.fs.rm("dbfs:/FileStore/tables/Staging/Customer/_delta_log/", recurse=True)
Sign up to request clarification or add additional context in comments.

1 Comment

Although this code might answer the question, I recommend that you also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.