cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Can't "copy into" new data to delta table after truncate old data

Danh_Hoa
New Contributor

Like title, i have a delta table with data of 22/9 and today i wanna remove old data and add new data of 23/9, i used 'truncate' and 'copy into' query but after 'truncate', nothing is added to table, what's happened with my table, file of old data still in location path, but nothing return when i run 'select' query

Danh_Hoa_0-1695454173304.png

Danh_Hoa_1-1695454194171.png

 

1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

Hi @Danh_Hoa , The issue you're experiencing might be due to a few reasons:

1. The Delta table you're trying to truncate and copy into might not actually be a Delta table. If the table was not created as a Delta table, you will not be able to perform Delta operations on it. This is indicated by the error DELTA_MISSING_DELTA_TABLE. Ensure that the table you're working with is indeed a Delta table.

2. The COPY INTO command might be failing due to corrupted files. As per the given documentation, if the data you are ingesting cannot be read due to some corruption issue, you can skip corrupted files by setting ignoreCorruptFiles to true in the FORMAT_OPTIONS.

However, if there are too many corrupted files, this might result in no data being copied into your table.

3. The data files for your Delta table might have been deleted due to log cleanup, as indicated by the error DELTA_MISSING_FILES_UNEXPECTED_VERSION.

In this case, you might need to restart your stream with a new checkpoint location and increase your delta.logRetentionDuration setting.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!