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.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group