Learn by fixing tests
© 2025-2026 Alex Cole. All Rights Reserved.
Spark Koans is an independent community tool.
Use MERGE to update existing rows and insert new ones. Replace ___ with the correct code.
___ blanks in the code editor with the correct PySpark code, then hit Run Code. Stuck? Try the Hint button._reset_delta_tables()
# Create target table
target_data = [("Alice", 100), ("Bob", 200)]
target_df = spark.createDataFrame(target_data, ["name", "balance"])
target_df.write.format("delta").save("/data/accounts")
# Source data with updates and new records
source_data = [("Alice", 150), ("Charlie", 300)] # Alice updated, Charlie is new
source_df = spark.createDataFrame(source_data, ["name", "balance"])Output will appear here...