Skip to content

Commit 5099c01

Browse files
committed
fix: fall back to Spark for DPP in non-AQE mode with native_datafusion scan
1 parent ab101c3 commit 5099c01

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

spark/src/main/scala/org/apache/comet/rules/CometScanRule.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,15 @@ case class CometScanRule(session: SparkSession)
140140
private def transformV1Scan(plan: SparkPlan, scanExec: FileSourceScanExec): SparkPlan = {
141141

142142
val hasDPP = scanExec.partitionFilters.exists(isDynamicPruningFilter)
143+
val aqeEnabled = session.sessionState.conf.adaptiveExecutionEnabled
143144

144-
// DPP is supported for native_datafusion scans via lazy partition serialization.
145-
// Only fall back for other scan implementations when DPP fallback is enabled.
145+
// DPP is supported for native_datafusion scans via lazy partition serialization,
146+
// but only in AQE mode where subqueries are properly prepared before execution.
147+
// In non-AQE mode, DPP subqueries aren't ready when the scan tries to use them.
146148
val scanImpl = COMET_NATIVE_SCAN_IMPL.get()
147-
if (COMET_DPP_FALLBACK_ENABLED.get() && hasDPP && scanImpl != SCAN_NATIVE_DATAFUSION) {
149+
val shouldFallbackForDPP = COMET_DPP_FALLBACK_ENABLED.get() && hasDPP &&
150+
(scanImpl != SCAN_NATIVE_DATAFUSION || !aqeEnabled)
151+
if (shouldFallbackForDPP) {
148152
return withInfo(scanExec, "Dynamic Partition Pruning is not supported for this scan type")
149153
}
150154

spark/src/test/scala/org/apache/comet/CometNativeScanDPPSuite.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class CometNativeScanDPPSuite extends CometTestBase {
3939
collect(plan) { case s: CometNativeScanExec => s }
4040
}
4141

42-
test("DPP - non-AQE mode with partitioned fact table") {
42+
// DPP in non-AQE mode requires subquery to be prepared before scan execution.
43+
// This is currently not supported by CometNativeScan - AQE mode is recommended.
44+
ignore("DPP - non-AQE mode with partitioned fact table") {
4345
withTempDir { dir =>
4446
val factDir = new File(dir, "fact")
4547
val dimDir = new File(dir, "dim")

0 commit comments

Comments
 (0)