Skip to content

fix: Bucketed scan fallback for native_datafusion Parquet scan #1720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2025
Merged
Changes from 2 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
21 changes: 14 additions & 7 deletions spark/src/main/scala/org/apache/comet/rules/CometScanRule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan
import org.apache.spark.sql.internal.SQLConf

import org.apache.comet.CometConf
import org.apache.comet.CometConf.{COMET_DPP_FALLBACK_ENABLED, COMET_EXEC_ENABLED, COMET_NATIVE_SCAN_IMPL, COMET_SCHEMA_EVOLUTION_ENABLED, SCAN_NATIVE_ICEBERG_COMPAT}
import org.apache.comet.CometSparkSessionExtensions.{isCometLoaded, isCometScanEnabled, withInfo}
import org.apache.comet.CometConf._
import org.apache.comet.CometSparkSessionExtensions.{isCometLoaded, isCometScanEnabled, withInfo, withInfos}
import org.apache.comet.parquet.{CometParquetScan, SupportsComet}

case class CometScanRule(session: SparkSession) extends Rule[SparkPlan] {
Expand Down Expand Up @@ -86,14 +86,21 @@ case class CometScanRule(session: SparkSession) extends Rule[SparkPlan] {
val fallbackReasons = new ListBuffer[String]()
if (!CometScanExec.isFileFormatSupported(r.fileFormat)) {
fallbackReasons += s"Unsupported file format ${r.fileFormat}"
return withInfo(scanExec, fallbackReasons.mkString(", "))
return withInfos(scanExec, fallbackReasons.toSet)
}

val scanImpl = COMET_NATIVE_SCAN_IMPL.get()
if (scanImpl == CometConf.SCAN_NATIVE_DATAFUSION && !COMET_EXEC_ENABLED.get()) {
fallbackReasons +=
s"Full native scan disabled because ${COMET_EXEC_ENABLED.key} disabled"
return withInfo(scanExec, fallbackReasons.mkString(", "))
return withInfos(scanExec, fallbackReasons.toSet)
}

if (scanImpl == CometConf.SCAN_NATIVE_DATAFUSION && scanExec.bucketedScan) {
// https://github.com/apache/datafusion-comet/issues/1719
fallbackReasons +=
"Full native scan disabled because bucketed scan is not supported"
return withInfos(scanExec, fallbackReasons.toSet)
}

val (schemaSupported, partitionSchemaSupported) = scanImpl match {
Expand All @@ -117,7 +124,7 @@ case class CometScanRule(session: SparkSession) extends Rule[SparkPlan] {
if (schemaSupported && partitionSchemaSupported) {
CometScanExec(scanExec, session)
} else {
withInfo(scanExec, fallbackReasons.mkString(", "))
withInfos(scanExec, fallbackReasons.toSet)
}

case _ =>
Expand Down Expand Up @@ -152,7 +159,7 @@ case class CometScanRule(session: SparkSession) extends Rule[SparkPlan] {
scanExec.copy(scan = cometScan),
runtimeFilters = scanExec.runtimeFilters)
} else {
withInfo(scanExec, fallbackReasons.mkString(", "))
withInfos(scanExec, fallbackReasons.toSet)
}

// Iceberg scan
Expand All @@ -179,7 +186,7 @@ case class CometScanRule(session: SparkSession) extends Rule[SparkPlan] {
scanExec.clone().asInstanceOf[BatchScanExec],
runtimeFilters = scanExec.runtimeFilters)
} else {
withInfo(scanExec, fallbackReasons.mkString(", "))
withInfos(scanExec, fallbackReasons.toSet)
}

case other =>
Expand Down
Loading