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:ย 

spark data frame parquet vs delta : rows Doesn't match

User16826994223
Honored Contributor III

I have data written in Delta on ADLS. As I understand the delta also internal file in parquet format but when Iread the file in different format I got different record count

spark.read.parquet()

 or 

spark.read.format('delta').load()

df = spark.read.format('delta').load("data")
df.count()
> 200000
 
df = spark.read.parquet("data")
df.count()
> 400000

As you can see the difference is quite big.

Is there something I misunderstood about delta vs parquet?

1 REPLY 1

User16826994223
Honored Contributor III

I think you have written in delta twice using overwrite mode

 .But Delta is versioned data format - when you use 

overwrite

, it doesn't delete previous data, it just writes new files, and don't delete files immediately - they are just marked as deleted in the manifest file that Delta uses. And when you read from Delta, it knows which files are deleted, or not, and read only actual data. Actual deletion of the data files happens when you're performing VACUUM on Delta lake.

But when you read with Parquet, it doesn't have information about deleted files, so it reads everything that you have in directory, so you get twice as many rows.

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