Skip to content
Closed
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 @@ -128,6 +128,7 @@ trait PredicateHelper extends AliasHelper with Logging {
def findExpressionAndTrackLineageDown(
exp: Expression,
plan: LogicalPlan): Option[(Expression, LogicalPlan)] = {
if (exp.references.isEmpty) return None

plan match {
case p: Project =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,34 @@ abstract class DynamicPartitionPruningSuiteBase
checkAnswer(df, Row(1150, 1) :: Row(1130, 4) :: Row(1140, 4) :: Nil)
}
}

test("SPARK-38570: Fix incorrect DynamicPartitionPruning caused by Literal") {
withSQLConf(SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "true") {
val df = sql(
"""
|SELECT f.store_id,
| f.date_id,
| s.state_province
|FROM (SELECT 4 AS store_id,
| date_id,
| product_id
| FROM fact_sk
| WHERE date_id >= 1300
| UNION ALL
| SELECT 5 AS store_id,
| date_id,
| product_id
| FROM fact_stats
| WHERE date_id <= 1000) f
|JOIN dim_store s
|ON f.store_id = s.store_id
|WHERE s.country = 'US'
|""".stripMargin)

checkPartitionPruningPredicate(df, withSubquery = false, withBroadcast = false)
checkAnswer(df, Row(4, 1300, "California") :: Row(5, 1000, "Texas") :: Nil)
}
}
}

abstract class DynamicPartitionPruningV1Suite extends DynamicPartitionPruningSuiteBase {
Expand Down