Tabellen cachen und aus dem Cache entfernen
In der Lektion haben wir gelernt, dass Tabellen gecacht werden können. Während ein DataFrame mit einer cache- oder persist-Operation gecacht wird, wird eine Tabelle mit der Operation cacheTable gecacht.
Eine Tabelle namens table1 ist verfügbar.
Diese Übung ist Teil des Kurses
Einführung in Spark SQL mit Python
Anleitung zur Übung
- Liste die Tabellen mit der Methode
listTables()auf. - Cache
table1und bestätige, dass sie gecacht ist. - Entferne
table1aus dem Cache und bestätige, dass sie nicht mehr gecacht ist.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# List the tables
print("Tables:\n", spark.____.____())
# Cache table1 and Confirm that it is cached
spark.catalog.____('table1')
print("table1 is cached: ", spark.catalog.____('table1'))
# Uncache table1 and confirm that it is uncached
spark.catalog.____('table1')
print("table1 is cached: ", spark.catalog.____('table1'))