Vergleich: Broadcast-Join vs. normaler Join
Du hast zwei Arten von Joins erstellt: normal und mit Broadcast. Jetzt möchte deine Führungskraft wissen, wie groß der Performance-Gewinn durch Spark-Optimierungen ist. Wenn die Ergebnisse vielversprechend sind, bekommst du mehr Spielraum, die Spark-Konfiguration nach Bedarf zu optimieren.
Deine DataFrames normal_df und broadcast_df stehen dir zur Verfügung.
Diese Übung ist Teil des Kurses
Datenbereinigung mit PySpark
Anleitung zur Übung
- Führe
.count()auf dem normalen DataFrame aus. - Führe
.count()auf dem Broadcast-DataFrame aus. - Gib die Anzahl und die Laufzeit der DataFrames aus und notiere eventuelle Unterschiede.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
start_time = time.time()
# Count the number of rows in the normal DataFrame
normal_count = ____
normal_duration = time.time() - start_time
start_time = time.time()
# Count the number of rows in the broadcast DataFrame
broadcast_count = ____
broadcast_duration = time.time() - start_time
# Print the counts and the duration of the tests
print("Normal count:\t\t%d\tduration: %f" % (normal_count, normal_duration))
print("Broadcast count:\t%d\tduration: %f" % (broadcast_count, broadcast_duration))