Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/13022#discussion_r62771468
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
@@ -531,18 +531,29 @@ private[hive] class
HiveMetastoreCatalog(sparkSession: SparkSession) extends Log
/**
* An override of the standard HDFS listing based catalog, that overrides
the partition spec with
* the information from the metastore.
+ * @param tableBasePath The default base path of the Hive metastore table
+ * @param partitionSpec The partition specifications from Hive metastore
*/
private[hive] class MetaStoreFileCatalog(
sparkSession: SparkSession,
- paths: Seq[Path],
- partitionSpecFromHive: PartitionSpec)
+ tableBasePath: Path,
+ override val partitionSpec: PartitionSpec)
extends ListingFileCatalog(
sparkSession,
- paths,
+ MetaStoreFileCatalog.getPaths(tableBasePath, partitionSpec),
Map.empty,
- Some(partitionSpecFromHive.partitionColumns)) {
+ Some(partitionSpec.partitionColumns)) {
+}
- override def partitionSpec(): PartitionSpec = partitionSpecFromHive
+private[hive] object MetaStoreFileCatalog {
+ /** Get the list of non-overalapping paths to list files in the for a
metastore table */
+ def getPaths(tableBasePath: Path, partitionSpec: PartitionSpec):
Seq[Path] = {
+ val basePathStr = tableBasePath.toUri.toString
+ val partitionsOutsideBasePath = partitionSpec
--- End diff --
@yin this is the hacky thing. I want to make sure that the seq of paths
does not contains both
`tableBasePath` as well as `tableBasePath/partition=1`. Having both parent
dir and sub dir might cause the listing to do duplicate work. One way to do
this is use substring match, as I have done. Another way to do it (just
occurred to me) is to
```
if (partitionSpec.partitions.nonEmpty) {
partitionSpec.partitions.map(_.path.toUri.toString)
} else {
tableBasePath
}
```
Which do you think is better?
---
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]