dropTempTable

dropTempTable drops the the specified temporary table. If the table has been cached/persisted before, it will also be unpersisted.

Note:

Temporary Tables do not persist across clusters and cluster restarts.

Syntax:

  • dropTempTable(sqlContext, “tableName”)

Parameters:

  • sqlContext: SQLContext. This is already created for you in the Databricks notebooks, do not recreate!
  • tableName: String, name of table to drop

Output:

  • NULL
# Create SparkR DataFrame from local R data frame
df <- createDataFrame(sqlContext, mtcars)
head(df)
# Register df as Temporary Table, with table name: tempTable
registerTempTable(df, "tempTable")

# View created tables
# column isTemporary indicates if table is temporary or not
head(sql(sqlContext, "SHOW tables"))
# Drop tempTable
dropTempTable(sqlContext, "tempTable")

# View created tables, "tempTable" is no longer in list
head(sql(sqlContext, "SHOW tables"))