-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29279][SQL] Merge SHOW NAMESPACES and SHOW DATABASES code path #26006
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
Conversation
|
cc: @rdblue / @cloud-fan |
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceResolution.scala
Outdated
Show resolved
Hide resolved
|
Test build #111705 has finished for PR 26006 at commit
|
|
Test build #111712 has finished for PR 26006 at commit
|
|
retest this please |
|
Test build #111771 has finished for PR 26006 at commit
|
|
@cloud-fan I merged with #25747 and is ready for review. |
| throw new AnalysisException( | ||
| "SHOW NAMESPACES is not supported with the session catalog.") | ||
|
|
||
| // TODO (SPARK-29014): we should check if the current catalog is session catalog here. |
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.
I can also handle the ShowTables case below as a separate PR (I have tests written up) if you want.
|
Test build #111784 has started for PR 26006 at commit |
| val CurrentCatalogAndNamespace(catalog, namespace) = nameParts | ||
| val ns = if (namespace.isEmpty) { None } else { Some(namespace) } | ||
| SetCatalogAndNamespace(catalogManager, Some(catalog.name()), ns) | ||
| SetCatalogAndNamespace(catalogManager, Some(catalog.name()), namespace) |
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.
This will always set the catalog, even if it is already the current? Why not use a rule that doesn't fill in the catalog and returns None instead?
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.
The check is done here:
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogManager.scala
Lines 128 to 137 in 8556710
| def setCurrentCatalog(catalogName: String): Unit = synchronized { | |
| // `setCurrentCatalog` is noop if it doesn't switch to a different catalog. | |
| if (currentCatalog.name() != catalogName) { | |
| _currentCatalogName = Some(catalogName) | |
| _currentNamespace = None | |
| // Reset the current database of v1 `SessionCatalog` when switching current catalog, so that | |
| // when we switch back to session catalog, the current namespace definitely is ["default"]. | |
| v1SessionCatalog.setCurrentDatabase(SessionCatalog.DEFAULT_DATABASE) | |
| } | |
| } |
| } | ||
|
|
||
| type CurrentCatalogAndNamespace = (CatalogPlugin, Seq[String]) | ||
| type CurrentCatalogAndNamespace = (CatalogPlugin, Option[Seq[String]]) |
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.
When I see this extractor/type name, it sounds like it should always return the current catalog. What about just naming this CatalogAndNamespace and document that the current catalog may be returned?
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.
Thanks, I will update it.
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
|
Overall looks good to me. The EXPLAIN change is a little concerning and I had some other minor comments. |
| } | ||
|
|
||
| type CurrentCatalogAndNamespace = (CatalogPlugin, Seq[String]) | ||
| type CatalogAndNamespace = (CatalogPlugin, Option[Seq[String]]) |
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.
This is short, maybe we don't need the type alias.
|
LGTM except one code style nit. We may need to wait for a few days until Jenkins is back online. |
|
+1 from me as well |
|
retest this please |
|
Test build #112013 has finished for PR 26006 at commit
|
|
thanks, merging to master! |
| throw new AnalysisException( | ||
| "SHOW NAMESPACES is not supported with the session catalog.") | ||
|
|
||
| // TODO (SPARK-29014): we should check if the current catalog is session catalog here. |
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.
@imback82 can you send a PR to fix SPARK-29014? It should be easy now.
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.
Yes, I will work on this. Thanks!
…f SHOW DATABASES ### What changes were proposed in this pull request? This is a followup of #26006 In #26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different. This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change. ### Why are the changes needed? Improve backward compatibility ### Does this PR introduce _any_ user-facing change? No (the legacy config is false by default) ### How was this patch tested? a new test Closes #31474 from cloud-fan/command-schema. Lead-authored-by: Wenchen Fan <cloud0fan@gmail.com> Co-authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…f SHOW DATABASES This is a followup of apache#26006 In apache#26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different. This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change. Improve backward compatibility No (the legacy config is false by default) a new test Closes apache#31474 from cloud-fan/command-schema. Lead-authored-by: Wenchen Fan <cloud0fan@gmail.com> Co-authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…ema of SHOW DATABASES This backports #31474 to 3.1/3.0 ### What changes were proposed in this pull request? This is a followup of #26006 In #26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different. This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change. ### Why are the changes needed? Improve backward compatibility ### Does this PR introduce _any_ user-facing change? No (the legacy config is false by default) ### How was this patch tested? a new test Closes #31486 from cloud-fan/command-schema. Authored-by: Wenchen Fan <cloud0fan@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…ema of SHOW DATABASES This backports #31474 to 3.1/3.0 This is a followup of #26006 In #26006 , we merged the v1 and v2 SHOW DATABASES/NAMESPACES commands, but we missed a behavior change that the output schema of SHOW DATABASES becomes different. This PR adds a legacy config to restore the old schema, with a migration guide item to mention this behavior change. Improve backward compatibility No (the legacy config is false by default) a new test Closes #31486 from cloud-fan/command-schema. Authored-by: Wenchen Fan <cloud0fan@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 7c87b48) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
Currently,
SHOW NAMESPACESandSHOW DATABASESare separate code paths. This PR merges two implementations.Why are the changes needed?
To remove code/behavior duplication
Does this PR introduce any user-facing change?
No
How was this patch tested?
Added new unit tests.