我是新手,通过数据框操作。
根据Apache Spark registerTempTable
和createTempView
的文档中给出的内容看起来很相似。
任何人都可以说出registerTempTable
和createTempView
之间究竟有什么区别吗?
由于
答案 0 :(得分:1)
已在spark 2.0.0+中弃用registerTempTable
方法,并在内部调用createOrReplaceTempView
。 Dataset
对象 -
private[sql] object Dataset {
/**
* Registers this Dataset as a temporary table using the given name. The lifetime of this
* temporary table is tied to the [[SparkSession]] that was used to create this Dataset.
*
* @group basic
* @since 1.6.0
*/
@deprecated("Use createOrReplaceTempView(viewName) instead.", "2.0.0")
def registerTempTable(tableName: String): Unit = {
createOrReplaceTempView(tableName)
}
............
}
答案 1 :(得分:1)
下面是两者的描述。
def createTempView(viewName: String): Unit
Creates a local temporary view using the given name. The lifetime of this
temporary view is tied to the SparkSession that was used to create this Dataset
def registerTempTable(tableName: String): Unit
Registers this Dataset as a temporary table using the given name. The
lifetime of this temporary table is tied to the SparkSession that was used to create this Dataset.
从图像中可以看到在Spark 2.0中不推荐使用registerTempTable。表示registerTempTable是Spark 2.0之前的功能。