Skip to content

Commit

Permalink
SPARK-36444: Remove OptimizeSubqueries from batch of PartitionPruning
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyum committed Aug 6, 2021
1 parent 72615bc commit be2abff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class SparkOptimizer(
override def defaultBatches: Seq[Batch] = (preOptimizationBatches ++ super.defaultBatches :+
Batch("Optimize Metadata Only Query", Once, OptimizeMetadataOnlyQuery(catalog)) :+
Batch("PartitionPruning", Once,
PartitionPruning,
OptimizeSubqueries) :+
PartitionPruning) :+
Batch("Pushdown Filters from PartitionPruning", fixedPoint,
PushDownPredicates) :+
Batch("Cleanup filters that cannot be pushed down", Once,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,20 @@ abstract class DynamicPartitionPruningSuiteBase

checkAnswer(df, Row(3, 2) :: Row(3, 2) :: Row(3, 2) :: Row(3, 2) :: Nil)
}

test("SPARK-36444: Remove OptimizeSubqueries from batch of PartitionPruning") {
withSQLConf(SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "true") {
val df = sql(
"""
|SELECT date_id, product_id FROM fact_sk f
|JOIN (select store_id + 3 as new_store_id from dim_store where country = 'US') s
|ON f.store_id = s.new_store_id
""".stripMargin)

checkPartitionPruningPredicate(df, false, true)
checkAnswer(df, Row(1150, 1) :: Row(1130, 4) :: Row(1140, 4) :: Nil)
}
}
}

abstract class DynamicPartitionPruningV1Suite extends DynamicPartitionPruningSuiteBase {
Expand Down

0 comments on commit be2abff

Please sign in to comment.