val sqlText = s"""
|CREATE GLOBAL TEMPORARY VIEW myTempCsvView
|(id LONG, name STRING)
|USING csv
""".stripMargin
// Logical commands are executed at analysis
scala> sql(sqlText)
res4: org.apache.spark.sql.DataFrame = []
scala> spark.catalog.listTables(spark.sharedState.globalTempViewManager.database).show
+-------------+-----------+-----------+---------+-----------+
| name| database|description|tableType|isTemporary|
+-------------+-----------+-----------+---------+-----------+
|mytempcsvview|global_temp| null|TEMPORARY| true|
+-------------+-----------+-----------+---------+-----------+
CreateTempViewUsing Logical Command
CreateTempViewUsing is a logical command for creating or replacing a temporary view (global or not) using a data source.
CreateTempViewUsing is created to represent CREATE TEMPORARY VIEW … USING SQL statements.
Executing Logical Command — run Method
run(sparkSession: SparkSession): Seq[Row]
|
Note
|
run is part of RunnableCommand Contract to execute (run) a logical command.
|
run creates a DataSource and requests it to resolve itself (i.e. create a BaseRelation).
run then requests the input SparkSession to create a DataFrame from the BaseRelation that is used to get the analyzed logical plan (that is the view definition of the temporary table).
Depending on the global flag, run requests the SessionCatalog to createGlobalTempView (global flag is on) or createTempView (global flag is off).
run throws an AnalysisException when executed with hive provider.
Hive data source can only be used with tables, you can't use it with CREATE TEMP VIEW USING
Creating CreateTempViewUsing Instance
CreateTempViewUsing takes the following when created:
-
Optional user-defined schema (as StructType)
-
Name of the data source provider
argString Method
argString: String
|
Note
|
argString is part of the TreeNode Contract to…FIXME.
|
argString…FIXME