cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

Merge version data files of Delta table

Data_Analytics1
Contributor III

Hi,

I am having one CDC enabled Delta table. In 256th version, table is having 50 data files. I want all to merge and create a single file. How can I merge all 50 data file and when I query for 256th version, I should get 1 data file? Is there any command which can optimize the file size?

2 REPLIES 2

Hi @Retired_mod ,

Here 256th version data files is of the CDF where I am querying the data for this version by following code:

display(spark.read.format("delta") \
  .option("readChangeFeed", "true") \
  .option("startingVersion", 256) \
  .option("endingVersion", 256) \
  .table("catalogName.schemaName.tableName"))

 Current version of the table is 300 but I wants to see what are the updates in 256th version. But what I found is that, this version is having 50 data files, reading which my code is displaying the data to me. As it is having 50 files, it is taking time to return the result. How to optimize the 256th version of the table when my current table version is 300?

OPTIMIZE command will optimize the current version (snapshot) of the table and creates the new version with lesser number of file.

Debayan
Databricks Employee
Databricks Employee

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