brkyvz commented on a change in pull request #25330: [SPARK-28565][SQL] 
DataFrameWriter saveAsTable support for V2 catalogs
URL: https://github.com/apache/spark/pull/25330#discussion_r310271005
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ##########
 @@ -648,8 +648,13 @@ class Analyzer(
           if catalog.isTemporaryTable(ident) =>
         u // temporary views take precedence over catalog table names
 
-      case u @ UnresolvedRelation(CatalogObjectIdentifier(Some(catalogPlugin), 
ident)) =>
-        loadTable(catalogPlugin, 
ident).map(DataSourceV2Relation.create).getOrElse(u)
+      case u @ UnresolvedRelation(CatalogObjectIdentifier(maybeCatalog, 
ident)) =>
+        // First try loading the table with a loadable catalog, then fallback 
to the session
+        // catalog if that exists
+        maybeCatalog.flatMap(loadTable(_, ident))
 
 Review comment:
   @rdblue Imagine the following use case. Let's say as the data science team, 
I have a database on the Hive MetaStore called `prod`. I have tables named 
like: `prod.tbl1`, `prod.tbl2`. Now, some other team (maybe data engineering 
team), creates a v2 catalog called `prod` and adds it to my environment.
   
   Won't the `prod` catalog hijack all my requests, and start failing to 
resolve the tables I had declared before, which I was expecting the 
V2SessionCatalog to resolve? I, as an unaware user, suddenly I have all my jobs 
failing and chaos ensues.
   

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

Reply via email to