You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/27 09:08:12 UTC

[GitHub] [spark] hddong opened a new pull request #32364: [SPARK-35242][SQL]support change catalog default database for spark

hddong opened a new pull request #32364:
URL: https://github.com/apache/spark/pull/32364


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error message, please read the guideline first:
        https://spark.apache.org/error-message-guidelines.html
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   Support change catalog default database for spark.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Spark catalog default database can only be `default`. When we can not access `default`, we will get Exception: 
   ```
   Permission denied: user [spark] does not have [SELECT] privilege on [spark_test])
   ```
    We should support change default datbase for catalog like `jdbc/thrift` does.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Added


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #32364:
URL: https://github.com/apache/spark/pull/32364#issuecomment-828286966


   cc @yaooqinn 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #32364: [SPARK-35242][SQL]support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32364:
URL: https://github.com/apache/spark/pull/32364#issuecomment-827461605


   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32364:
URL: https://github.com/apache/spark/pull/32364#discussion_r621969421



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
##########
@@ -42,13 +42,14 @@ import org.apache.spark.sql.catalyst.util.{CharVarcharUtils, StringUtils}
 import org.apache.spark.sql.connector.catalog.CatalogManager
 import org.apache.spark.sql.errors.QueryCompilationErrors
 import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.internal.StaticSQLConf.CATALOG_DEFAULT_DATABASE
 import org.apache.spark.sql.internal.StaticSQLConf.GLOBAL_TEMP_DATABASE
 import org.apache.spark.sql.types.StructType
 import org.apache.spark.sql.util.{CaseInsensitiveStringMap, PartitioningUtils}
 import org.apache.spark.util.Utils
 
 object SessionCatalog {
-  val DEFAULT_DATABASE = "default"
+  val DEFAULT_DATABASE = SQLConf.get.getConf(CATALOG_DEFAULT_DATABASE)

Review comment:
       can we read the conf in `class SessionCatalog` so that it can be changed per session?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] github-actions[bot] commented on pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #32364:
URL: https://github.com/apache/spark/pull/32364#issuecomment-912871339


   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] github-actions[bot] closed pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #32364:
URL: https://github.com/apache/spark/pull/32364


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32364:
URL: https://github.com/apache/spark/pull/32364#discussion_r639396997



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
##########
@@ -48,7 +48,7 @@ import org.apache.spark.sql.util.{CaseInsensitiveStringMap, PartitioningUtils}
 import org.apache.spark.util.Utils
 
 object SessionCatalog {
-  val DEFAULT_DATABASE = "default"
+  val DEFAULT_DATABASE = SQLConf.get.defaultDatabase

Review comment:
       BTW it's a bit tricky to access the active SQLConf in scala object. Can we read the conf in `BaseSessionStateBuilder` and pass it to `SessionCatalog`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32364:
URL: https://github.com/apache/spark/pull/32364#discussion_r621968124



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/StaticSQLConf.scala
##########
@@ -37,6 +37,12 @@ object StaticSQLConf {
     .stringConf
     .createWithDefault(Utils.resolveURI("spark-warehouse").toString)
 
+  val CATALOG_DEFAULT_DATABASE = buildStaticConf("spark.sql.catalog.default.database")

Review comment:
       Every catalog is free to define its own default database/namespace, see `CatalogPlugin.defaultNamespace`.
   
   What we need here is a config to change the default database for the session catalog. How about `spark.sql.catalog.$SESSION_CATALOG_NAME.defaultDatabase`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] yaooqinn commented on a change in pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #32364:
URL: https://github.com/apache/spark/pull/32364#discussion_r621989624



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/StaticSQLConf.scala
##########
@@ -37,6 +37,12 @@ object StaticSQLConf {
     .stringConf
     .createWithDefault(Utils.resolveURI("spark-warehouse").toString)
 
+  val CATALOG_DEFAULT_DATABASE = buildStaticConf("spark.sql.catalog.default.database")
+    .doc("The default database for session catalog.")
+    .version("3.2.0")
+    .stringConf
+    .createWithDefault("default")

Review comment:
       Can we test this in `CliSuite`? AFAIK, spark actually never got a chance to create the default database if not exists, which will be done during hive metastore client initialization. If it is configured to `default2` for example, Spark now will get the opportunity to create and there might be 2 default databases then.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] yaooqinn commented on pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #32364:
URL: https://github.com/apache/spark/pull/32364#issuecomment-828293337


   > Permission denied: user [spark] does not have [SELECT] privilege on [spark_test])
   
   Can you detail the context or operation that leads to this exception?
   
   It looks to have nothing to do with the `default` database.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] hddong commented on a change in pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
hddong commented on a change in pull request #32364:
URL: https://github.com/apache/spark/pull/32364#discussion_r628003003



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/StaticSQLConf.scala
##########
@@ -37,6 +37,12 @@ object StaticSQLConf {
     .stringConf
     .createWithDefault(Utils.resolveURI("spark-warehouse").toString)
 
+  val CATALOG_DEFAULT_DATABASE = buildStaticConf("spark.sql.catalog.default.database")
+    .doc("The default database for session catalog.")
+    .version("3.2.0")
+    .stringConf
+    .createWithDefault("default")

Review comment:
       IMO, the database need exits when not connect to `default`. Now, spark shell(submit) always need a read permision of `default` when init.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] hddong commented on a change in pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
hddong commented on a change in pull request #32364:
URL: https://github.com/apache/spark/pull/32364#discussion_r628003003



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/StaticSQLConf.scala
##########
@@ -37,6 +37,12 @@ object StaticSQLConf {
     .stringConf
     .createWithDefault(Utils.resolveURI("spark-warehouse").toString)
 
+  val CATALOG_DEFAULT_DATABASE = buildStaticConf("spark.sql.catalog.default.database")
+    .doc("The default database for session catalog.")
+    .version("3.2.0")
+    .stringConf
+    .createWithDefault("default")

Review comment:
       IMO, the database need exits when not connect to `default`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] hddong commented on pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
hddong commented on pull request #32364:
URL: https://github.com/apache/spark/pull/32364#issuecomment-848397877


   @cloud-fan @yaooqinn : please have a review for this PR again when free.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a change in pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32364:
URL: https://github.com/apache/spark/pull/32364#discussion_r639396667



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
##########
@@ -48,7 +48,7 @@ import org.apache.spark.sql.util.{CaseInsensitiveStringMap, PartitioningUtils}
 import org.apache.spark.util.Utils
 
 object SessionCatalog {
-  val DEFAULT_DATABASE = "default"
+  val DEFAULT_DATABASE = SQLConf.get.defaultDatabase

Review comment:
       This makes it look like it's a runtime config. Let's write `getConf(StaticSQLConf.CATALOG_DEFAULT_DATABASE)`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #32364:
URL: https://github.com/apache/spark/pull/32364#issuecomment-828076850


   cc @aokolnychyi and @cloud-fan FYI


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] hddong commented on pull request #32364: [SPARK-35242][SQL] Support change catalog default database for spark

Posted by GitBox <gi...@apache.org>.
hddong commented on pull request #32364:
URL: https://github.com/apache/spark/pull/32364#issuecomment-834147167


   @cloud-fan @yaooqinn : thanks for your review. 
   In my case hive permission managed by ranger, and all users have not read access to `default`.
   And please review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org