beliefer commented on code in PR #43949:
URL: https://github.com/apache/spark/pull/43949#discussion_r1407415324


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Utils.scala:
##########
@@ -151,6 +153,27 @@ private[sql] object DataSourceV2Utils extends Logging {
     }
   }
 
+  /**
+   * Returns the table provider for the given format, or None if it cannot be 
found.
+   */
+  def getTableProvider(provider: String, conf: SQLConf): Option[TableProvider] 
= {
+    // Return earlier since `lookupDataSourceV2` may fail to resolve provider 
"hive" to
+    // `HiveFileFormat`, when running tests in sql/core.
+    if (DDLUtils.isHiveTable(Some(provider))) return None
+    DataSource.lookupDataSourceV2(provider, conf) match {
+      // TODO(SPARK-28396): Currently file source v2 can't work with tables.
+      case Some(_: FileDataSourceV2) => None
+      case o => o
+    }
+  }
+
+  /**
+   * Check if the provider is a v2 provider.
+   */
+  def isV2Provider(provider: String, conf: SQLConf): Boolean = {

Review Comment:
   Because `isV2Provider` is only used for  `ResolveSessionCatalog`, move this 
back to `ResolveSessionCatalog`.



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Utils.scala:
##########
@@ -151,6 +153,27 @@ private[sql] object DataSourceV2Utils extends Logging {
     }
   }
 
+  /**
+   * Returns the table provider for the given format, or None if it cannot be 
found.
+   */
+  def getTableProvider(provider: String, conf: SQLConf): Option[TableProvider] 
= {
+    // Return earlier since `lookupDataSourceV2` may fail to resolve provider 
"hive" to
+    // `HiveFileFormat`, when running tests in sql/core.
+    if (DDLUtils.isHiveTable(Some(provider))) return None
+    DataSource.lookupDataSourceV2(provider, conf) match {
+      // TODO(SPARK-28396): Currently file source v2 can't work with tables.
+      case Some(_: FileDataSourceV2) => None
+      case o => o

Review Comment:
   ```
   case p: Some(v) if !v.isInstanceOf[FileDataSourceV2] => p
   case _ => None
   ```



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

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to