Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/12945#discussion_r62618235
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -2306,8 +2306,37 @@ class Dataset[T] private[sql](
* @group basic
* @since 1.6.0
*/
+ @deprecated("Use createTempView(tableName, replaceIfExists = true)
instead.", "2.0.0")
def registerTempTable(tableName: String): Unit = {
- sparkSession.registerTable(toDF(), tableName)
+ createTempView(tableName, replaceIfExists = true)
+ }
+
+ /**
+ * Creates a temporary view using the given name. The lifetime of this
+ * temporary view is tied to the [[SQLContext]] that was used to create
this Dataset.
+ *
+ * @throws AnalysisException if the view name already exists
+ *
+ * @group basic
+ * @since 2.0.0
+ */
+ @throws[AnalysisException]
+ def createTempView(viewName: String): Unit = {
+ createTempView(viewName, replaceIfExists = false)
+ }
+
+ /**
+ * Creates a temporary view using the given name. The lifetime of this
+ * temporary view is tied to the [[SQLContext]] that was used to create
this Dataset.
+ *
+ * @throws AnalysisException if replaceIfExists flag is false and the
view name already exists.
+ *
+ * @group basic
+ * @since 2.0.0
+ */
+ @throws[AnalysisException]
+ def createTempView(viewName: String, replaceIfExists: Boolean): Unit = {
--- End diff --
But we already have createTempView.
What I'm saying is to define two functions:
1. createTempView(viewName: String)
2. createOrReplaceTempView(viewName: String)
Then it is very obvious when looking at their usage to know what the
behavior is. Otherwise we will run into the issue of not knowing what the 2nd
parameter mean unless somebody looks up the documentation, e.g.
`createTempView("abcd", false)` - what does the false mean?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]