This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new e48cb8cc69a9 [SPARK-54448][SQL][DOCS] Fix docs and error message
because CREATE TEMP VIEW does not support IF NOT EXISTS
e48cb8cc69a9 is described below
commit e48cb8cc69a9421bb8e7b438df31dd097c2d3529
Author: Cheng Pan <[email protected]>
AuthorDate: Fri Nov 21 12:40:00 2025 -0800
[SPARK-54448][SQL][DOCS] Fix docs and error message because CREATE TEMP
VIEW does not support IF NOT EXISTS
### What changes were proposed in this pull request?
Currently, Spark SQL supports `CREATE [ OR REPLACE ] [ [ GLOBAL ] TEMPORARY
] VIEW [ IF NOT EXISTS ] view_identifier ...` syntax, but the implementation
forbids using `CREATE [ GLOBAL ] TEMPORARY VIEW` with `IF NOT EXISTS`, this is
likely an incompleted feature.
And this was also provided as an example in the docs, but actually does not
work.
https://spark.apache.org/docs/4.0.1/sql-ref-syntax-ddl-create-view.html
<img width="890" height="366" alt="image"
src="https://github.com/user-attachments/assets/d3a30055-866b-4307-904e-10e908b953a2"
/>
In addition, the error condition `TEMP_TABLE_OR_VIEW_ALREADY_EXISTS`'s
message suggests "add the IF NOT EXISTS clause", which does not work either.
```
spark-sql (default)> CREATE GLOBAL TEMPORARY VIEW v AS SELECT 1;
spark-sql (default)> CREATE GLOBAL TEMPORARY VIEW v AS SELECT 1;
[TEMP_TABLE_OR_VIEW_ALREADY_EXISTS] Cannot create the temporary view `v`
because it already exists.
Choose a different name, drop or replace the existing view, or add the IF
NOT EXISTS clause to tolerate pre-existing views. SQLSTATE: 42P07
```
### Why are the changes needed?
Fix wrong docs and error condition message.
### Does this PR introduce _any_ user-facing change?
It only updates the docs and error condition message, with no functionality
changes.
### How was this patch tested?
<img width="928" height="1652" alt="image"
src="https://github.com/user-attachments/assets/ec6d4a35-285a-4431-b456-60d2c4c8b1ac"
/>
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #53153 from pan3793/SPARK-54448.
Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
(cherry picked from commit 6c6dd0f5c7fe796f5e446bf9888f5908de4dabbe)
Signed-off-by: Dongjoon Hyun <[email protected]>
---
common/utils/src/main/resources/error/error-conditions.json | 2 +-
docs/sql-ref-syntax-ddl-create-view.md | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/common/utils/src/main/resources/error/error-conditions.json
b/common/utils/src/main/resources/error/error-conditions.json
index 555f310e512e..b79e44a7984a 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -5919,7 +5919,7 @@
"TEMP_TABLE_OR_VIEW_ALREADY_EXISTS" : {
"message" : [
"Cannot create the temporary view <relationName> because it already
exists.",
- "Choose a different name, drop or replace the existing view, or add the
IF NOT EXISTS clause to tolerate pre-existing views."
+ "Choose a different name, drop or replace the existing view."
],
"sqlState" : "42P07"
},
diff --git a/docs/sql-ref-syntax-ddl-create-view.md
b/docs/sql-ref-syntax-ddl-create-view.md
index 21174f12300e..2d832636b38f 100644
--- a/docs/sql-ref-syntax-ddl-create-view.md
+++ b/docs/sql-ref-syntax-ddl-create-view.md
@@ -47,6 +47,7 @@ CREATE [ OR REPLACE ] [ [ GLOBAL ] TEMPORARY ] VIEW [ IF NOT
EXISTS ] view_ident
* **IF NOT EXISTS**
Creates a view if it does not exist.
+ This clause is not supported for `TEMPORARY` views yet.
* **view_identifier**
@@ -86,8 +87,8 @@ CREATE OR REPLACE VIEW experienced_employee
AS SELECT id, name FROM all_employee
WHERE working_years > 5;
--- Create a global temporary view `subscribed_movies` if it does not exist.
-CREATE GLOBAL TEMPORARY VIEW IF NOT EXISTS subscribed_movies
+-- Create a global temporary view `subscribed_movies`.
+CREATE GLOBAL TEMPORARY VIEW subscribed_movies
AS SELECT mo.member_id, mb.full_name, mo.movie_title
FROM movies AS mo INNER JOIN members AS mb
ON mo.member_id = mb.id;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]