-
- Downloads
[SPARK-17338][SQL] add global temp view
## What changes were proposed in this pull request? Global temporary view is a cross-session temporary view, which means it's shared among all sessions. Its lifetime is the lifetime of the Spark application, i.e. it will be automatically dropped when the application terminates. It's tied to a system preserved database `global_temp`(configurable via SparkConf), and we must use the qualified name to refer a global temp view, e.g. SELECT * FROM global_temp.view1. changes for `SessionCatalog`: 1. add a new field `gloabalTempViews: GlobalTempViewManager`, to access the shared global temp views, and the global temp db name. 2. `createDatabase` will fail if users wanna create `global_temp`, which is system preserved. 3. `setCurrentDatabase` will fail if users wanna set `global_temp`, which is system preserved. 4. add `createGlobalTempView`, which is used in `CreateViewCommand` to create global temp views. 5. add `dropGlobalTempView`, which is used in `CatalogImpl` to drop global temp view. 6. add `alterTempViewDefinition`, which is used in `AlterViewAsCommand` to update the view definition for local/global temp views. 7. `renameTable`/`dropTable`/`isTemporaryTable`/`lookupRelation`/`getTempViewOrPermanentTableMetadata`/`refreshTable` will handle global temp views. changes for SQL commands: 1. `CreateViewCommand`/`AlterViewAsCommand` is updated to support global temp views 2. `ShowTablesCommand` outputs a new column `database`, which is used to distinguish global and local temp views. 3. other commands can also handle global temp views if they call `SessionCatalog` APIs which accepts global temp views, e.g. `DropTableCommand`, `AlterTableRenameCommand`, `ShowColumnsCommand`, etc. changes for other public API 1. add a new method `dropGlobalTempView` in `Catalog` 2. `Catalog.findTable` can find global temp view 3. add a new method `createGlobalTempView` in `Dataset` ## How was this patch tested? new tests in `SQLViewSuite` Author: Wenchen Fan <wenchen@databricks.com> Closes #14897 from cloud-fan/global-temp-view.
Showing
- core/src/main/scala/org/apache/spark/internal/config/package.scala 7 additions, 0 deletions...main/scala/org/apache/spark/internal/config/package.scala
- docs/sql-programming-guide.md 40 additions, 5 deletionsdocs/sql-programming-guide.md
- examples/src/main/java/org/apache/spark/examples/sql/JavaSparkSQLExample.java 28 additions, 2 deletions...va/org/apache/spark/examples/sql/JavaSparkSQLExample.java
- examples/src/main/python/sql/basic.py 25 additions, 0 deletionsexamples/src/main/python/sql/basic.py
- examples/src/main/scala/org/apache/spark/examples/sql/SparkSQLExample.scala 25 additions, 0 deletions...scala/org/apache/spark/examples/sql/SparkSQLExample.scala
- project/MimaExcludes.scala 3 additions, 1 deletionproject/MimaExcludes.scala
- python/pyspark/sql/catalog.py 17 additions, 1 deletionpython/pyspark/sql/catalog.py
- python/pyspark/sql/context.py 1 addition, 1 deletionpython/pyspark/sql/context.py
- python/pyspark/sql/dataframe.py 23 additions, 2 deletionspython/pyspark/sql/dataframe.py
- sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4 5 additions, 3 deletions...in/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala 5 additions, 5 deletions...ala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/GlobalTempViewManager.scala 121 additions, 0 deletions...he/spark/sql/catalyst/catalog/GlobalTempViewManager.scala
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala 150 additions, 39 deletions...rg/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
- sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala 41 additions, 7 deletionssql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
- sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala 19 additions, 1 deletion...src/main/scala/org/apache/spark/sql/catalog/Catalog.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala 5 additions, 3 deletions...scala/org/apache/spark/sql/execution/QueryExecution.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala 14 additions, 5 deletions...scala/org/apache/spark/sql/execution/SparkSqlParser.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala 14 additions, 11 deletions...in/scala/org/apache/spark/sql/execution/command/ddl.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala 6 additions, 5 deletions...scala/org/apache/spark/sql/execution/command/tables.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala 77 additions, 73 deletions.../scala/org/apache/spark/sql/execution/command/views.scala
Loading
Please register or sign in to comment