Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/14897#discussion_r81463019 --- Diff: docs/sql-programming-guide.md --- @@ -220,6 +220,40 @@ The `sql` function enables applications to run SQL queries programmatically and </div> +## Global Temporary View + +Temporay views in Spark SQL are session-scoped and will disappear if the session that creates it +terminates. If you want to have a temporary view that is shared among all sessions and keep alive +until the Spark application terminiates, you can create a global temporary view. Global temporary +view is tied to a system preserved database `global_temp`, and we must use the qualified name to +refer it, e.g. `SELECT * FROM global_temp.view1`. + +<div class="codetabs"> +<div data-lang="scala" markdown="1"> +{% include_example global_temp_view scala/org/apache/spark/examples/sql/SparkSQLExample.scala %} +</div> + +<div data-lang="java" markdown="1"> +{% include_example global_temp_view java/org/apache/spark/examples/sql/JavaSparkSQLExample.java %} +</div> + +<div data-lang="python" markdown="1"> +{% include_example global_temp_view python/sql/basic.py %} +</div> + +<div data-lang="sql" markdown="1"> + +{% highlight sql %} + +CREATE GLOBAL TEMPORARY VIEW temp_view AS SELECT a + 1, b * 2 FROM tbl + +SELECT * FROM global_temp.temp_view + +{% endhighlight %} + +</div> --- End diff -- We need one more </div>
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org