Github user jiangxb1987 commented on a diff in the pull request: https://github.com/apache/spark/pull/16233#discussion_r95083902 --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala --- @@ -465,6 +466,48 @@ class SessionCatalogSuite extends SparkFunSuite { assert(plan == SubqueryAlias("range", tmpView, Option(TableIdentifier("vw1")))) } + test("look up view relation") { + val externalCatalog = newBasicCatalog() + val sessionCatalog = new SessionCatalog(externalCatalog) + val metadata = externalCatalog.getTable("db3", "view1") + sessionCatalog.setCurrentDatabase("default") + // Look up a view. + assert(metadata.viewText.isDefined) + val view = normalizeExprIds(View(desc = metadata, output = metadata.schema.toAttributes, + child = CatalystSqlParser.parsePlan(metadata.viewText.get))) + assert( + normalizeExprIds(sessionCatalog.lookupRelation(TableIdentifier("view1", Some("db3")))) + == SubqueryAlias("view1", view, Some(TableIdentifier("view1", Some("db3"))))) + // Look up a view using current database of the session catalog. + sessionCatalog.setCurrentDatabase("db3") + assert( + normalizeExprIds(sessionCatalog.lookupRelation(TableIdentifier("view1"))) + == SubqueryAlias("view1", view, Some(TableIdentifier("view1")))) + } + + /** --- End diff -- The problem is both the `PlanTest` and `SparkFunSuite` are abstract classes, should we make `PlanTest` a trait?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org