我正在使用spark2.3和scala 2.11。
所以我想知道这种方法是否过时了(兼容性问题?)
谢谢!
答案 0 :(得分:1)
createGlobalTempView()
也可以使用ApiDoucment的功能。
这是sourceCode近3115行。
给您一个演示来处理您的数据。
val spark = SparkSession.
builder.
appName("Simple Application").
master("local").
getOrCreate()
val df = spark.read.json("my.json")
// Register the DataFrame as a SQL temporary view
df.createOrReplaceTempView("people1")//:people
val sqlDF = spark.sql("SELECT * FROM people1 ")
println("createOrReplaceTempView")
sqlDF.show()
// Register the DataFrame as a global temporary view
df.createGlobalTempView("people2")
// Global temporary view is tied to a system preserved database `global_temp`
val sqlDF2 = spark.sql("SELECT * FROM global_temp.people2")
sqlDF2.show()