Skip to content

Commit

Permalink
[SPARK-34436][SQL] DPP support LIKE ANY/ALL expression
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

This pr make DPP support LIKE ANY/ALL expression:
```sql
SELECT date_id, product_id FROM fact_sk f
JOIN dim_store s
ON f.store_id = s.store_id WHERE s.country LIKE ANY ('%D%E%', '%A%B%')
```

### Why are the changes needed?

Improve query performance.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Unit test.

Closes apache#31563 from wangyum/SPARK-34436.

Lead-authored-by: Yuming Wang <[email protected]>
Co-authored-by: Yuming Wang <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
  • Loading branch information
2 people authored and shipenglei committed Oct 15, 2021
1 parent 4cbe03f commit 0703f89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ object PartitionPruning extends Rule[LogicalPlan] with PredicateHelper {
case _: BinaryComparison => true
case _: In | _: InSet => true
case _: StringPredicate => true
case _: MultiLikeBase => true
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,26 @@ abstract class DynamicPartitionPruningSuiteBase
checkAnswer(df, Nil)
}
}

test("SPARK-34436: DPP support LIKE ANY/ALL expression") {
withSQLConf(SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "true") {
val df = sql(
"""
|SELECT date_id, product_id FROM fact_sk f
|JOIN dim_store s
|ON f.store_id = s.store_id WHERE s.country LIKE ANY ('%D%E%', '%A%B%')
""".stripMargin)

checkPartitionPruningPredicate(df, false, true)

checkAnswer(df,
Row(1030, 2) ::
Row(1040, 2) ::
Row(1050, 2) ::
Row(1060, 2) :: Nil
)
}
}
}

class DynamicPartitionPruningSuiteAEOff extends DynamicPartitionPruningSuiteBase {
Expand Down

0 comments on commit 0703f89

Please sign in to comment.