In Apache Spark, the function registerTempTable() was an old API (deprecated since Spark 2.0 and removed in Spark 3.0) that allowed you to register a DataFrame as a temporary table (view) so it could be queried using SQL syntax.
📌 Usage (before Spark 2.0)
🚨 Deprecation
-
registerTempTable("name")was replaced withcreateOrReplaceTempView("name"). -
Reason:
registerTempTableonly worked with SQLContext and was being phased out in favor of SparkSession unified APIs.
📌 Modern Equivalent
📌 Difference Between Views
-
createOrReplaceTempView(name)-
Session-scoped (disappears when the SparkSession ends).
-
Can be replaced if you register the same name again.
-
-
createGlobalTempView(name)-
Global across sessions but tied to the Spark application.
-
Registered under the
global_tempdatabase.
-
✅ In short:
registerTempTable() = old API (now gone).
createOrReplaceTempView() = the correct replacement.

浙公网安备 33010602011771号