-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-54415][SQL] CREATE GLOBAL TEMPORARY VIEW / TEMPORARY VIEW supports IF NOT EXISTS clause #53129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[SPARK-54415][SQL] CREATE GLOBAL TEMPORARY VIEW / TEMPORARY VIEW supports IF NOT EXISTS clause #53129
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,9 +55,17 @@ class GlobalTempViewManager(database: String) { | |
| def create( | ||
| name: String, | ||
| viewDefinition: TemporaryViewRelation, | ||
| ignoreIfExists: Boolean, | ||
| overrideIfExists: Boolean): Unit = synchronized { | ||
| if (!overrideIfExists && viewDefinitions.contains(name)) { | ||
| throw new TempTableAlreadyExistsException(name) | ||
| if (ignoreIfExists && overrideIfExists) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So why both
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
obviously, Snowflake has the same behavior https://docs.snowflake.com/en/sql-reference/sql/create-view#general-usage-notes
|
||
| throw QueryCompilationErrors.createViewWithBothIfNotExistsAndReplaceError() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it okay to reuse |
||
| } | ||
| if (viewDefinitions.contains(name)) { | ||
| if (ignoreIfExists) { | ||
| return | ||
| } else if (!overrideIfExists) { | ||
| throw new TempTableAlreadyExistsException(name) | ||
| } | ||
| } | ||
| viewDefinitions.put(name, viewDefinition) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can reuse this for other resource types, e.g. TABLE, FUNCTION, PROCEDURE