clearCache

clearCache removes all cached Spark SQL tables from the in-memory cache.

Syntax:

  • clearCache(sqlContext)

Parameters:

  • sqlContext: SQLContext. This is already created for you in the Databricks notebooks, do not recreate!

Output:

  • NULL
# Create SparkR DataFrame using the faithful dataset from R
df <- createDataFrame(sqlContext, faithful)

# Register df as Temporary Table, with table name: tempTable
registerTempTable(df, "tempTable")

# Cache Spark SQL table in memory
cacheTable(sqlContext, "tempTable")
# Clear all cached tables in the sqlContext
clearCache(sqlContext)