cloud-fan commented on a change in pull request #25771: [SPARK-28970][SQL]
Implement USE CATALOG/NAMESPACE for Data Source V2
URL: https://github.com/apache/spark/pull/25771#discussion_r328436187
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/finishAnalysis.scala
##########
@@ -78,11 +78,13 @@ object ComputeCurrentTime extends Rule[LogicalPlan] {
/** Replaces the expression of CurrentDatabase with the current database name.
*/
-case class GetCurrentDatabase(sessionCatalog: SessionCatalog) extends
Rule[LogicalPlan] {
+case class GetCurrentDatabase(catalogManager: CatalogManager) extends
Rule[LogicalPlan] {
def apply(plan: LogicalPlan): LogicalPlan = {
+ import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
+
plan transformAllExpressions {
case CurrentDatabase() =>
- Literal.create(sessionCatalog.getCurrentDatabase, StringType)
+ Literal.create(catalogManager.currentNamespace.quoted, StringType)
Review comment:
super nit: shall we keep the `catalogManager.currentNamespace.quoted` in a
variable and use it here? Then we can avoid calling
`catalogManager.currentNamespace.quoted` many times.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]