For spark 2.0 the APIs are
For temporary views
spark.catalog.dropTempView("df")
For global views
spark.catalog.dropGlobalTempView("df")
From the Documentation
abstract def
dropGlobalTempView(viewName: String): Boolean
Drops the global temporary view with the given view name in the catalog. If the view has been cached before, then it will also be uncached.
Global temporary view is cross-session. Its lifetime is the lifetime of the Spark application, i.e. it will be automatically dropped when the application terminates. It's tied to a system preserved database global_temp, and we must use the qualified name to refer a global temp view, e.g. SELECT * FROM global_temp.view1.
viewName
the unqualified name of the temporary view to be dropped.
returns
true if the view is dropped successfully, false otherwise.
abstract def
dropTempView(viewName: String): Boolean
Drops the local temporary view with the given view name in the catalog. If the view has been cached before, then it will also be uncached.
Local temporary view is session-scoped. Its lifetime is the lifetime of the session that created it, i.e. it will be automatically dropped when the session terminates. It's not tied to any databases, i.e. we can't use db1.view1 to reference a local temporary view.
Note that, the return type of this method was Unit in Spark 2.0, but changed to Boolean in Spark 2.1.
viewName
the name of the temporary view to be dropped.
returns
true if the view is dropped successfully, false otherwise.