开始使用免费开始使用

缓存与取消缓存表

在本课中,我们学习了可以对表进行缓存。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'))
编辑并运行代码