Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/5339#discussion_r27711434
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
@@ -213,13 +215,42 @@ private[hive] class HiveMetastoreCatalog(hive:
HiveContext) extends Catalog with
private def convertToParquetRelation(metastoreRelation:
MetastoreRelation): LogicalRelation = {
val metastoreSchema =
StructType.fromAttributes(metastoreRelation.output)
val mergeSchema = hive.convertMetastoreParquetWithSchemaMerging
- val parquetOptions = Map(
- ParquetRelation2.METASTORE_SCHEMA -> metastoreSchema.json,
- ParquetRelation2.MERGE_SCHEMA -> mergeSchema.toString)
// NOTE: Instead of passing Metastore schema directly to
`ParquetRelation2`, we have to
// serialize the Metastore schema to JSON and pass it as a data source
option because of the
// evil case insensitivity issue, which is reconciled within
`ParquetRelation2`.
+ val parquetOptions = Map(
+ ParquetRelation2.METASTORE_SCHEMA -> metastoreSchema.json,
+ ParquetRelation2.MERGE_SCHEMA -> mergeSchema.toString)
+ val tableIdentifier =
+ QualifiedTableName(metastoreRelation.databaseName,
metastoreRelation.tableName)
+
+ def getCached(
+ tableIdentifier: QualifiedTableName,
+ pathsInMetastore: Seq[String],
+ schemaInMetastore: StructType,
+ partitionSpecInMetastore: Option[PartitionSpec]):
Option[LogicalRelation] = {
+ cachedDataSourceTables.getIfPresent(tableIdentifier) match {
+ case null => None // Cache miss
+ case logical @ LogicalRelation(parquetRelation: ParquetRelation2)
=>
+ // If we have the same paths, same schema, and same partition
spec,
+ // we will use the cached Parquet Relation.
+ val useCached =
+ parquetRelation.paths == pathsInMetastore &&
--- End diff --
Maybe turn both of them into sets and then do the comparison.
---
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]