Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.spark.sql.execution.datasources

import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.analysis.MultiInstanceRelation
import org.apache.spark.sql.catalyst.catalog.CatalogTable
import org.apache.spark.sql.catalyst.expressions.{AttributeMap, AttributeReference}
Expand Down Expand Up @@ -69,7 +70,10 @@ case class LogicalRelation(
case _ => // Do nothing.
}

override def simpleString: String = s"Relation[${Utils.truncatedString(output, ",")}] $relation"
override def simpleString: String = {
s"Relation[${Utils.truncatedString(output, ",")}] $relation " +
s"${catalogTable.map(_.identifier.identifier).getOrElse("")}"
}
}

object LogicalRelation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,33 +190,20 @@ private[hive] class HiveMetastoreCatalog(sparkSession: SparkSession) extends Log
} else {
selectParquetLocationDirectories(relation.tableMeta.identifier.table, Option(rootPath))
}
withTableCreationLock(tableIdentifier, {
val cached = getCached(
tableIdentifier,
paths,
metastoreSchema,
fileFormatClass,
None)
val logicalRelation = cached.getOrElse {
val (dataSchema, updatedTable) = inferIfNeeded(relation, options, fileFormat)
val created =
LogicalRelation(
DataSource(
sparkSession = sparkSession,
paths = paths.map(_.toString),
userSpecifiedSchema = Option(dataSchema),
// We don't support hive bucketed tables, only ones we write out.
bucketSpec = None,
options = options,
className = fileType).resolveRelation(),
table = updatedTable)

catalogProxy.cacheTable(tableIdentifier, created)
created
}

logicalRelation
})
// SPY-1453: disable the cache completely until we migrated to partitioning
val (dataSchema, updatedTable) = inferIfNeeded(relation, options, fileFormat)
val created =
LogicalRelation(
DataSource(
sparkSession = sparkSession,
paths = paths.map(_.toString),
userSpecifiedSchema = Option(dataSchema),
// We don't support hive bucketed tables, only ones we write out.
bucketSpec = None,
options = options,
className = fileType).resolveRelation(),
table = updatedTable)
created
}
// The inferred schema may have different field names as the table schema, we should respect
// it, but also respect the exprId in table relation output.
Expand Down