-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29511][SQL] DataSourceV2: Support CREATE NAMESPACE #26166
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
daa17c1
initial checkin
imback82 27066a5
Finishing up
imback82 1298b0f
Merge branch 'master' into create_namespace
imback82 08728d3
add more tests
imback82 c1e6687
Address comments
imback82 0fce441
Merge branch 'master' into create_namespace
imback82 6f80ff4
change ifNotExist logic.
imback82 970338c
address comments
imback82 db5b1c9
Merge branch 'master' into create_namespace
imback82 132cd7f
Address PR comments
imback82 3fd447d
style change
imback82 f7fa8ed
Merge branch 'master' into create_namespace
imback82 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add more tests
- Loading branch information
commit 08728d3bc2778b4ccd2a023bfa476b0fa61b4e83
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ package org.apache.spark.sql.connector | |
| import scala.collection.JavaConverters._ | ||
|
|
||
| import org.apache.spark.sql._ | ||
| import org.apache.spark.sql.catalyst.analysis.{CannotReplaceMissingTableException, NoSuchDatabaseException, NoSuchTableException, TableAlreadyExistsException} | ||
| import org.apache.spark.sql.catalyst.analysis.{CannotReplaceMissingTableException, NamespaceAlreadyExistsException, NoSuchDatabaseException, NoSuchTableException, TableAlreadyExistsException} | ||
| import org.apache.spark.sql.connector.catalog._ | ||
| import org.apache.spark.sql.connector.catalog.CatalogManager.SESSION_CATALOG_NAME | ||
| import org.apache.spark.sql.internal.SQLConf | ||
|
|
@@ -764,12 +764,30 @@ class DataSourceV2SQLSuite | |
| assert(expected === df.collect()) | ||
| } | ||
|
|
||
| test("CreateNameSpace: session catalog") { | ||
| test("CreateNameSpace: basic tests") { | ||
| // Session catalog is used. | ||
| sql("CREATE NAMESPACE ns") | ||
| testShowNamespaces("SHOW NAMESPACES", Seq("default", "ns")) | ||
|
|
||
| // V2 non-session catalog is used. | ||
| sql("CREATE NAMESPACE testcat.ns1.ns2") | ||
| testShowNamespaces("SHOW NAMESPACES testcat", Seq("ns1")) | ||
| testShowNamespaces("SHOW NAMESPACES IN testcat", Seq("ns1")) | ||
| testShowNamespaces("SHOW NAMESPACES IN testcat.ns1", Seq("ns1.ns2")) | ||
|
|
||
| // TODO: Add tests for validating namespace metadata when DESCRIBE NAMESPACE is available. | ||
|
Contributor
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. I will create a JIRA for this and follow up. |
||
| } | ||
|
|
||
| test("CreateNameSpace: test handling of 'IF NOT EXIST'") { | ||
| sql("CREATE NAMESPACE IF NOT EXISTS testcat.ns1") | ||
|
|
||
| // The 'ns1' namespace already exists, so this should fail. | ||
| val exception = intercept[NamespaceAlreadyExistsException] { | ||
| sql("CREATE NAMESPACE testcat.ns1") | ||
| } | ||
| assert(exception.getMessage.contains("Namespace 'ns1' already exists")) | ||
|
|
||
| // The following will be no-op since the namespace already exists. | ||
| sql("CREATE NAMESPACE IF NOT EXISTS testcat.ns1") | ||
| } | ||
|
|
||
| test("ShowNamespaces: show root namespaces with default v2 catalog") { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.