Skip to content

Commit

Permalink
Update 2024-08-06-delta-lake-avec-apache-spark.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lepiaf committed Jul 18, 2024
1 parent 57bcdb8 commit 9a105f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion _articles/fr/2024-08-06-delta-lake-avec-apache-spark.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,15 @@ delta_table_path = "datalake/count-bike-nantes"
if DeltaTable.isDeltaTable(spark, delta_table_path):
dt = DeltaTable.forPath(spark, "datalake/count-bike-nantes")
transformation(df)
dt.alias("gold_table").merge(transformation(df).alias("fresh_data"), condition="fresh_data.loop_number = gold_table.loop_number").execute()
(
dt
.alias("gold_table")
.merge(transformation(df).alias("fresh_data"), condition="fresh_data.loop_number = gold_table.loop_number")
.whenMatchedUpdateAll()
.whenNotMatchedInsertAll()
.whenNotMatchedBySourceDelete()
.execute()
)
else:
transformation(df).write.format("delta").partitionBy("date").save(delta_table_path)
```
Expand Down

0 comments on commit 9a105f6

Please sign in to comment.