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 2020/12/29 13:23:45 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #30963: [SPARK-33926][SQL] Improve the error message from resolving of v1 database name

cloud-fan commented on a change in pull request #30963:
URL: https://github.com/apache/spark/pull/30963#discussion_r549702998



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
##########
@@ -710,4 +678,29 @@ class ResolveSessionCatalog(
       case _ => false
     }
   }
+
+  private class DatabaseInSessionCatalog(namespace: Seq[String]) {
+    def name: String = {
+      val len = namespace.length
+      if (len == 0) {
+        throw new AnalysisException("Database from v1 session catalog is not specified")
+      } else if (len > 1) {
+        val quotedNames = namespace.map(quoteIfNeeded).mkString(".")
+        throw new AnalysisException(
+          s"Nested databases are not supported by v1 session catalog: $quotedNames")
+      } else {
+        namespace(0)
+      }
+    }
+  }
+
+  private object DatabaseInSessionCatalog {
+    def unapply(resolved: ResolvedNamespace): Option[DatabaseInSessionCatalog] = {
+      if (isSessionCatalog(resolved.catalog)) {
+        Some(new DatabaseInSessionCatalog(resolved.namespace))

Review comment:
       What if we fail earlier in the pattern match? Then we can remove the class `DatabaseInSessionCatalog` and apply the check here.




----------------------------------------------------------------
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