cacheTableΒΆ

cacheTable persists a Spark SQL Table in memory.

Syntax:

  • cacheTable(“sqlTable”)

Parameters:

  • sqlTable: String, Name of Spark SQL table

Output:

  • NULL
require(SparkR)

# Create SparkDataFrame using the faithful dataset from R
df <- createDataFrame(faithful)

# Displays the content of the SparkDataFrame to stdout
head(df)
# Register df as Temporary Table, with table name: tempTable
registerTempTable(df, "tempTable")

# Cache Spark SQL table in memory
cacheTable("tempTable")
# Perform SQL operations on cached tempTable
query <- sql("SELECT * FROM tempTable WHERE waiting > 60")
head(query)