Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/16621#discussion_r96570432
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
---
@@ -215,37 +215,44 @@ case class DataSourceAnalysis(conf: CatalystConf)
extends Rule[LogicalPlan] {
/**
- * Replaces [[SimpleCatalogRelation]] with data source table if its table
property contains data
- * source information.
+ * Replaces [[SimpleCatalogRelation]] with data source table if its table
provider is not hive.
*/
class FindDataSourceTable(sparkSession: SparkSession) extends
Rule[LogicalPlan] {
- private def readDataSourceTable(
- sparkSession: SparkSession,
- simpleCatalogRelation: SimpleCatalogRelation): LogicalPlan = {
- val table = simpleCatalogRelation.catalogTable
- val pathOption = table.storage.locationUri.map("path" -> _)
- val dataSource =
- DataSource(
- sparkSession,
- userSpecifiedSchema = Some(table.schema),
- partitionColumns = table.partitionColumnNames,
- bucketSpec = table.bucketSpec,
- className = table.provider.get,
- options = table.storage.properties ++ pathOption)
-
- LogicalRelation(
- dataSource.resolveRelation(),
- expectedOutputAttributes = Some(simpleCatalogRelation.output),
- catalogTable = Some(table))
+ private def readDataSourceTable(relation: SimpleCatalogRelation):
LogicalPlan = {
+ val table = relation.catalogTable
+ val cache = sparkSession.sessionState.catalog.tableRelationCache
+ val withHiveSupport =
+
sparkSession.sparkContext.conf.get(StaticSQLConf.CATALOG_IMPLEMENTATION) ==
"hive"
+
+ cache.get(table.qualifiedIdentifier, new Callable[LogicalPlan]() {
+ override def call(): LogicalPlan = {
+ val pathOption = table.storage.locationUri.map("path" -> _)
+ val dataSource =
+ DataSource(
+ sparkSession,
+ userSpecifiedSchema = Some(table.schema),
--- End diff --
```
// In older version(prior to 2.1) of Spark, the table schema
can be empty and should be
// inferred at runtime. We should still support it.
```
Is it still valid?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]