Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/17015#discussion_r102818575
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
@@ -155,66 +153,58 @@ private[hive] class
HiveMetastoreCatalog(sparkSession: SparkSession) extends Log
val cached = getCached(
tableIdentifier,
rootPaths,
- metastoreRelation,
metastoreSchema,
fileFormatClass,
- bucketSpec,
Some(partitionSchema))
val logicalRelation = cached.getOrElse {
- val sizeInBytes =
-
metastoreRelation.stats(sparkSession.sessionState.conf).sizeInBytes.toLong
+ val sizeInBytes =
relation.stats(sparkSession.sessionState.conf).sizeInBytes.toLong
val fileIndex = {
- val index = new CatalogFileIndex(
- sparkSession, metastoreRelation.catalogTable, sizeInBytes)
+ val index = new CatalogFileIndex(sparkSession,
relation.tableMeta, sizeInBytes)
if (lazyPruningEnabled) {
index
} else {
index.filterPartitions(Nil) // materialize all the
partitions in memory
}
}
- val partitionSchemaColumnNames =
partitionSchema.map(_.name.toLowerCase).toSet
- val dataSchema =
- StructType(metastoreSchema
- .filterNot(field =>
partitionSchemaColumnNames.contains(field.name.toLowerCase)))
+ val dataSchema = relation.tableMeta.dataSchema
- val relation = HadoopFsRelation(
+ val fs = HadoopFsRelation(
location = fileIndex,
partitionSchema = partitionSchema,
dataSchema = dataSchema,
- bucketSpec = bucketSpec,
- fileFormat = defaultSource,
+ // We don't support hive bucketed tables, only ones we write
out.
+ bucketSpec = None,
+ fileFormat = fileFormatClass.newInstance(),
options = options)(sparkSession = sparkSession)
- val created = LogicalRelation(relation,
- catalogTable = Some(metastoreRelation.catalogTable))
+ val created = LogicalRelation(fs, catalogTable =
Some(relation.tableMeta))
tableRelationCache.put(tableIdentifier, created)
created
}
logicalRelation
})
} else {
- val rootPath = metastoreRelation.hiveQlTable.getDataLocation
+ val rootPath = tablePath
withTableCreationLock(tableIdentifier, {
- val cached = getCached(tableIdentifier,
+ val cached = getCached(
+ tableIdentifier,
Seq(rootPath),
- metastoreRelation,
metastoreSchema,
fileFormatClass,
- bucketSpec,
None)
val logicalRelation = cached.getOrElse {
val created =
LogicalRelation(
DataSource(
sparkSession = sparkSession,
paths = rootPath.toString :: Nil,
- userSpecifiedSchema = Some(metastoreRelation.schema),
- bucketSpec = bucketSpec,
+ userSpecifiedSchema = Some(metastoreSchema),
+ bucketSpec = None,
--- End diff --
Like what we did above, adding the same comment?
```
// We don't support hive bucketed tables, only ones we write out.
```
---
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]