cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Feature request delta tables : drop duplicate rows

MRTN
New Contributor III

A deltaTable.dropDuplicates(columns) would be a very nice feature, simplifying the complex procedures that are suggested online.

Or am I missing any existing procedures that can be done withouth merge operations or similar?

1 ACCEPTED SOLUTION

Accepted Solutions

MRTN
New Contributor III
3 REPLIES 3

Hubert-Dudek
Esteemed Contributor III

It would be helpful. Currently, the best way is just to read the table as a dataframe and use Pyspark dropDuplicates().

# Load the table
df = spark.table("yourtable")
 
# Drop duplicates based on the Id and Name columns
df = df.dropDuplicates(["Id", "Name"])
 
# Overwrite the original table with the resulting dataframe
df.write.mode("overwrite").saveAsTable("yourtable")

This worked perfectly, and much easier than all the complex solutions that are suggested online.

MRTN
New Contributor III
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.