yuchenhuo commented on a change in pull request #26957: [SPARK-30314] Add
identifier and catalog information to DataSourceV2Relation
URL: https://github.com/apache/spark/pull/26957#discussion_r370512201
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/command/PlanResolutionSuite.scala
##########
@@ -1072,6 +1075,54 @@ class PlanResolutionSuite extends AnalysisTest {
}
}
+ val DSV2ResolutionTests = {
+ val v2SessionCatalogTable =
s"${CatalogManager.SESSION_CATALOG_NAME}.v2Table"
+ Seq(
+ ("ALTER TABLE testcat.tab ALTER COLUMN i TYPE bigint", false),
+ ("ALTER TABLE tab ALTER COLUMN i TYPE bigint", false),
+ (s"ALTER TABLE $v2SessionCatalogTable ALTER COLUMN i TYPE bigint", true),
+ ("INSERT INTO TABLE tab VALUES (1)", false),
+ ("INSERT INTO TABLE testcat.tab VALUES (1)", false),
+ (s"INSERT INTO TABLE $v2SessionCatalogTable VALUES (1)", true),
+ ("DESC TABLE tab", false),
+ ("DESC TABLE testcat.tab", false),
+ (s"DESC TABLE $v2SessionCatalogTable", true),
+ ("SHOW TBLPROPERTIES tab", false),
+ ("SHOW TBLPROPERTIES testcat.tab", false),
+ (s"SHOW TBLPROPERTIES $v2SessionCatalogTable", true),
+ ("SELECT * from tab", false),
+ ("SELECT * from testcat.tab", false),
+ (s"SELECT * from ${CatalogManager.SESSION_CATALOG_NAME}.v2Table", true)
+ )
+ }
+
+ DSV2ResolutionTests.foreach { case (sql, isSessionCatlog) =>
+ test(s"Data source V2 relation resolution '$sql'") {
+ val parsed = parseAndResolve(sql, withDefault = true)
+ val catlogIdent = if (isSessionCatlog) v2SessionCatalog else testCat
+ val tableIdent = if (isSessionCatlog) "v2Table" else "tab"
+ parsed match {
+ case AlterTable(_, _, r: DataSourceV2Relation, _) =>
+ assert(r.catalog.exists(_ == catlogIdent))
+ assert(r.identifier.exists(_.name() == tableIdent))
+ case Project(_, r: DataSourceV2Relation) =>
+ assert(r.catalog.exists(_ == catlogIdent))
+ assert(r.identifier.exists(_.name() == tableIdent))
+ case InsertIntoStatement(r: DataSourceV2Relation, _, _, _, _) =>
+ assert(r.catalog.exists(_ == catlogIdent))
+ assert(r.identifier.exists(_.name() == tableIdent))
+ case DescribeRelation(r: ResolvedTable, _, _) =>
Review comment:
@brkyvz by looking at @cloud-fan's recent change on this, I'm a little
uncertain whether we should be passing the table identifier with the
DataSourceV2Relation. It feels like the Analyzer should resolve
DataSourceV2Relation to ResolvedTable if table information should be included?
----------------------------------------------------------------
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]