-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-30018][SQL] Support ALTER DATABASE SET OWNER syntax #26775
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
Changes from all commits
3c96091
7188587
56ac955
25cf227
dd1d52b
c1680a4
824cb6a
406c5c2
10e1bc3
d4017b2
42ec005
e5d695e
162fbf0
ae1ebec
bb2f919
c76e5b5
2182992
514b78a
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 |
|---|---|---|
|
|
@@ -64,9 +64,16 @@ public interface SupportsNamespaces extends CatalogPlugin { | |
| String PROP_OWNER_TYPE = "ownerType"; | ||
|
|
||
| /** | ||
| * The list of reserved namespace properties. | ||
| * The list of reserved namespace properties, which can not be removed or changed directly by | ||
| * the syntax: | ||
| * {{ | ||
| * ALTER NAMESPACE ... SET PROPERTIES ... | ||
|
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. do we support UNSET?
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. we have no ALTER NAMESPACE UNSET PROPERTIES yet |
||
| * }} | ||
| * | ||
| * They need specific syntax to modify | ||
| */ | ||
| List<String> RESERVED_PROPERTIES = Arrays.asList(PROP_COMMENT, PROP_LOCATION); | ||
| List<String> RESERVED_PROPERTIES = | ||
| Arrays.asList(PROP_COMMENT, PROP_LOCATION, PROP_OWNER_NAME, PROP_OWNER_TYPE); | ||
|
|
||
| /** | ||
| * Return a default namespace for the catalog. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import org.apache.spark.sql.internal.SQLConf.V2_SESSION_CATALOG_IMPLEMENTATION | |
| import org.apache.spark.sql.sources.SimpleScanSource | ||
| import org.apache.spark.sql.types.{BooleanType, LongType, StringType, StructType} | ||
| import org.apache.spark.sql.util.CaseInsensitiveStringMap | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| class DataSourceV2SQLSuite | ||
| extends InsertIntoTests(supportsDynamicOverwrite = true, includeSQLOnlyTests = true) | ||
|
|
@@ -884,7 +885,8 @@ class DataSourceV2SQLSuite | |
| .isEmpty, s"$key is a reserved namespace property and ignored") | ||
| val meta = | ||
| catalog("testcat").asNamespaceCatalog.loadNamespaceMetadata(Array("reservedTest")) | ||
| assert(meta.get(key) === null, "reserved properties should not have side effects") | ||
| assert(meta.get(key) == null || !meta.get(key).contains("foo"), | ||
| "reserved properties should not have side effects") | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -967,7 +969,9 @@ class DataSourceV2SQLSuite | |
| assert(description === Seq( | ||
| Row("Namespace Name", "ns2"), | ||
| Row("Description", "test namespace"), | ||
| Row("Location", "/tmp/ns_test") | ||
| Row("Location", "/tmp/ns_test"), | ||
| Row("Owner Name", Utils.getCurrentUserName()), | ||
| Row("Owner Type", "USER") | ||
| )) | ||
| } | ||
| } | ||
|
|
@@ -982,6 +986,8 @@ class DataSourceV2SQLSuite | |
| Row("Namespace Name", "ns2"), | ||
| Row("Description", "test namespace"), | ||
| Row("Location", "/tmp/ns_test"), | ||
| Row("Owner Name", Utils.getCurrentUserName()), | ||
| Row("Owner Type", "USER"), | ||
| Row("Properties", "((a,b),(b,a),(c,c))") | ||
| )) | ||
| } | ||
|
|
@@ -1010,7 +1016,8 @@ class DataSourceV2SQLSuite | |
| .isEmpty, s"$key is a reserved namespace property and ignored") | ||
| val meta = | ||
| catalog("testcat").asNamespaceCatalog.loadNamespaceMetadata(Array("reservedTest")) | ||
| assert(meta.get(key) === null, "reserved properties should not have side effects") | ||
| assert(meta.get(key) == null || !meta.get(key).contains("foo"), | ||
| "reserved properties should not have side effects") | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1025,7 +1032,25 @@ class DataSourceV2SQLSuite | |
| assert(descriptionDf.collect() === Seq( | ||
| Row("Namespace Name", "ns2"), | ||
| Row("Description", "test namespace"), | ||
| Row("Location", "/tmp/ns_test_2") | ||
| Row("Location", "/tmp/ns_test_2"), | ||
| Row("Owner Name", Utils.getCurrentUserName()), | ||
| Row("Owner Type", "USER") | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| test("AlterNamespaceSetOwner using v2 catalog") { | ||
| withNamespace("testcat.ns1.ns2") { | ||
| sql("CREATE NAMESPACE IF NOT EXISTS testcat.ns1.ns2 COMMENT " + | ||
| "'test namespace' LOCATION '/tmp/ns_test_3'") | ||
|
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. not related to this PR, does ANSI SQL define a OWNER clause for CREATE TABLE/NAMESPACE?
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. I checked the Standard and did not find such a clause for |
||
| sql("ALTER NAMESPACE testcat.ns1.ns2 SET OWNER ROLE adminRole") | ||
| val descriptionDf = sql("DESCRIBE NAMESPACE EXTENDED testcat.ns1.ns2") | ||
| assert(descriptionDf.collect() === Seq( | ||
| Row("Namespace Name", "ns2"), | ||
| Row("Description", "test namespace"), | ||
| Row("Location", "/tmp/ns_test_3"), | ||
| Row("Owner Name", "adminRole"), | ||
| Row("Owner Type", "ROLE") | ||
| )) | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.