Skip to content
Open
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 @@ -77,7 +77,16 @@ case class HiveTableScanExecTransformer(
partitionWithReadFileFormats

override def getDistinctPartitionReadFileFormats: Set[ReadFileFormat] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a comment for this method? Mark it as only for validation.

distinctReadFileFormats
if (
relation.isPartitioned &&
basePrunedPartitions.exists(_.getInputFormatClass != tableDesc.getInputFileFormatClass)
) {
basePrunedPartitions.map {
partition => getReadFileFormat(HiveClientImpl.fromHivePartition(partition).storage)
}.toSet
} else {
Set(fileFormat)
}

override def getPartitionSchema: StructType = relation.tableMeta.partitionSchema

Expand Down Expand Up @@ -120,9 +129,6 @@ case class HiveTableScanExecTransformer(

@transient private lazy val partitions: Seq[Partition] = partitionWithReadFileFormats.unzip._1

@transient private lazy val distinctReadFileFormats: Set[ReadFileFormat] =
partitionWithReadFileFormats.iterator.map(_._2).toSet

@transient override lazy val fileFormat: ReadFileFormat =
getReadFileFormat(relation.tableMeta.storage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,30 @@ abstract private[hive] class AbstractHiveTableScanExec(
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] = {
// This is used on the driver side, so it is important to avoid executing subqueries
@transient lazy val basePrunedPartitions: Seq[HivePartition] = {
if (relation.prunedPartitions.nonEmpty) {
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
} else {
rawPartitions
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: reduce redundant judgment

  @transient lazy val prunedPartitions: Seq[HivePartition] =
    if (partitionPruningPred.forall(!ExecSubqueryExpression.hasSubquery(_)) ||
        (sparkSession.sessionState.conf.metastorePartitionPruning &&
          partitionPruningPred.nonEmpty))
      basePrunedPartitions
    } else {
      prunePartitions(basePrunedPartitions)
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure?

if (relation.prunedPartitions.nonEmpty) {
val hivePartitions =
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
if (partitionPruningPred.forall(!ExecSubqueryExpression.hasSubquery(_))) {
hivePartitions
basePrunedPartitions
} else {
prunePartitions(hivePartitions)
prunePartitions(basePrunedPartitions)
}
} else if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
basePrunedPartitions
} else {
if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
rawPartitions
} else {
prunePartitions(rawPartitions)
}
prunePartitions(basePrunedPartitions)
}
}

// exposed for tests
@transient lazy val rawPartitions: Seq[HivePartition] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,30 @@ abstract private[hive] class AbstractHiveTableScanExec(
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] = {
// This is used on the driver side, so it is important to avoid executing subqueries
@transient lazy val basePrunedPartitions: Seq[HivePartition] = {
if (relation.prunedPartitions.nonEmpty) {
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
} else {
rawPartitions
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] =
if (relation.prunedPartitions.nonEmpty) {
val hivePartitions =
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
if (partitionPruningPred.forall(!ExecSubqueryExpression.hasSubquery(_))) {
hivePartitions
basePrunedPartitions
} else {
prunePartitions(hivePartitions)
prunePartitions(basePrunedPartitions)
}
} else if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
basePrunedPartitions
} else {
if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
rawPartitions
} else {
prunePartitions(rawPartitions)
}
prunePartitions(basePrunedPartitions)
}
}

// exposed for tests
@transient lazy val rawPartitions: Seq[HivePartition] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,30 @@ abstract private[hive] class AbstractHiveTableScanExec(
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] = {
// This is used on the driver side, so it is important to avoid executing subqueries
@transient lazy val basePrunedPartitions: Seq[HivePartition] = {
if (relation.prunedPartitions.nonEmpty) {
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
} else {
rawPartitions
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] =
if (relation.prunedPartitions.nonEmpty) {
val hivePartitions =
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
if (partitionPruningPred.forall(!ExecSubqueryExpression.hasSubquery(_))) {
hivePartitions
basePrunedPartitions
} else {
prunePartitions(hivePartitions)
prunePartitions(basePrunedPartitions)
}
} else if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
basePrunedPartitions
} else {
if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
rawPartitions
} else {
prunePartitions(rawPartitions)
}
prunePartitions(basePrunedPartitions)
}
}

// exposed for tests
@transient lazy val rawPartitions: Seq[HivePartition] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,30 @@ abstract private[hive] class AbstractHiveTableScanExec(
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] = {
// This is used on the driver side, so it is important to avoid executing subqueries
@transient lazy val basePrunedPartitions: Seq[HivePartition] = {
if (relation.prunedPartitions.nonEmpty) {
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
} else {
rawPartitions
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] =
if (relation.prunedPartitions.nonEmpty) {
val hivePartitions =
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
if (partitionPruningPred.forall(!ExecSubqueryExpression.hasSubquery(_))) {
hivePartitions
basePrunedPartitions
} else {
prunePartitions(hivePartitions)
prunePartitions(basePrunedPartitions)
}
} else if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
basePrunedPartitions
} else {
if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
rawPartitions
} else {
prunePartitions(rawPartitions)
}
prunePartitions(basePrunedPartitions)
}
}

// exposed for tests
@transient lazy val rawPartitions: Seq[HivePartition] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,30 @@ abstract private[hive] class AbstractHiveTableScanExec(
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] = {
// This is used on the driver side, so it is important to avoid executing subqueries
@transient lazy val basePrunedPartitions: Seq[HivePartition] = {
if (relation.prunedPartitions.nonEmpty) {
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
} else {
rawPartitions
}
}

@transient lazy val prunedPartitions: Seq[HivePartition] =
if (relation.prunedPartitions.nonEmpty) {
val hivePartitions =
relation.prunedPartitions.get.map(HiveClientImpl.toHivePartition(_, hiveQlTable))
if (partitionPruningPred.forall(!ExecSubqueryExpression.hasSubquery(_))) {
hivePartitions
basePrunedPartitions
} else {
prunePartitions(hivePartitions)
prunePartitions(basePrunedPartitions)
}
} else if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
basePrunedPartitions
} else {
if (
sparkSession.sessionState.conf.metastorePartitionPruning &&
partitionPruningPred.nonEmpty
) {
rawPartitions
} else {
prunePartitions(rawPartitions)
}
prunePartitions(basePrunedPartitions)
}
}

// exposed for tests
@transient lazy val rawPartitions: Seq[HivePartition] = {
Expand Down
Loading