開始使用免費開始

快取與取消快取資料表

在課程中我們學到可以對資料表進行快取。DataFrame 會用 cachepersist 作業來快取,而資料表則使用 cacheTable 作業。

名為 table1 的資料表已可使用。

本練習屬於課程

Python Spark SQL 入門

檢視課程

練習說明

  • 使用 listTables() 方法列出所有資料表。
  • 快取 table1,並確認它已被快取。
  • 取消快取 table1,並確認它已被取消快取。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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'))
編輯並執行程式碼