Skip to content
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

fix: isCometEnabled name conflict #1569

Merged
merged 5 commits into from
Mar 26, 2025
Merged
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 @@ -55,7 +55,7 @@ import org.apache.spark.sql.types.{DoubleType, FloatType}

import org.apache.comet.CometConf._
import org.apache.comet.CometExplainInfo.getActualPlan
import org.apache.comet.CometSparkSessionExtensions.{createMessage, getCometBroadcastNotEnabledReason, getCometShuffleNotEnabledReason, isANSIEnabled, isCometBroadCastForceEnabled, isCometEnabled, isCometExecEnabled, isCometJVMShuffleMode, isCometNativeShuffleMode, isCometScan, isCometScanEnabled, isCometShuffleEnabled, isSpark40Plus, shouldApplySparkToColumnar, withInfo, withInfos}
import org.apache.comet.CometSparkSessionExtensions.{createMessage, getCometBroadcastNotEnabledReason, getCometShuffleNotEnabledReason, isANSIEnabled, isCometBroadCastForceEnabled, isCometExecEnabled, isCometJVMShuffleMode, isCometLoaded, isCometNativeShuffleMode, isCometScan, isCometScanEnabled, isCometShuffleEnabled, isSpark40Plus, shouldApplySparkToColumnar, withInfo, withInfos}
import org.apache.comet.parquet.{CometParquetScan, SupportsComet}
import org.apache.comet.rules.RewriteJoin
import org.apache.comet.serde.OperatorOuterClass.Operator
Expand Down Expand Up @@ -93,8 +93,8 @@ class CometSparkSessionExtensions

case class CometScanRule(session: SparkSession) extends Rule[SparkPlan] {
override def apply(plan: SparkPlan): SparkPlan = {
if (!isCometEnabled(conf) || !isCometScanEnabled(conf)) {
if (!isCometEnabled(conf)) {
if (!isCometLoaded(conf) || !isCometScanEnabled(conf)) {
if (!isCometLoaded(conf)) {
withInfo(plan, "Comet is not enabled")
} else if (!isCometScanEnabled(conf)) {
withInfo(plan, "Comet Scan is not enabled")
Expand Down Expand Up @@ -975,8 +975,8 @@ class CometSparkSessionExtensions
}
}

// We shouldn't transform Spark query plan if Comet is disabled.
if (!isCometEnabled(conf)) return plan
// We shouldn't transform Spark query plan if Comet is not loaded.
if (!isCometLoaded(conf)) return plan

if (!isCometExecEnabled(conf)) {
// Comet exec is disabled, but for Spark shuffle, we still can use Comet columnar shuffle
Expand Down Expand Up @@ -1172,9 +1172,9 @@ object CometSparkSessionExtensions extends Logging {
}

/**
* Checks whether Comet extension should be enabled for Spark.
* Checks whether Comet extension should be loaded for Spark.
*/
private[comet] def isCometEnabled(conf: SQLConf): Boolean = {
private[comet] def isCometLoaded(conf: SQLConf): Boolean = {
if (isBigEndian) {
logInfo("Comet extension is disabled because platform is big-endian")
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ class CometSparkSessionExtensionsSuite extends CometTestBase {

import CometSparkSessionExtensions._

test("isCometEnabled") {
test("isCometLoaded") {
val conf = new SQLConf

conf.setConfString(CometConf.COMET_ENABLED.key, "false")
assert(!isCometEnabled(conf))
assert(!isCometLoaded(conf))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use CometSparkSessionExtensions.isCometEnabled instead of renaming the method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I thought about it but since both version of isCometEnabled would be still accessible, especially due to

  import CometSparkSessionExtensions._

, this may cause future issues for using isCometEnabled like adding new tests.
I am ok with CometSparkSessionExtensions.isCometEnabled but changing the name entirely is more future proof? WDTY @parthchandra @comphead
Also CometSparkSessionExtensions.isCometEnabled is checking NativeBase.isLoaded, so I think isCometLoaded makes sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I thought about it but since both version of isCometEnabled would be still accessible, especially due to

  import CometSparkSessionExtensions._

, this may cause future issues for using isCometEnabled like adding new tests. I am ok with CometSparkSessionExtensions.isCometEnabled but changing the name entirely is more future proof? WDTY @parthchandra @comphead Also CometSparkSessionExtensions.isCometEnabled is checking NativeBase.isLoaded, so I think isCometLoaded makes sense

It used to be CometSparkSessionExtensions.isCometEnabled and was changed here: badbd37

I'm okay with the new name though.


// Since the native lib is probably already loaded due to previous tests, we reset it here
NativeBase.setLoaded(false)

conf.setConfString(CometConf.COMET_ENABLED.key, "true")
val oldProperty = System.getProperty("os.name")
System.setProperty("os.name", "foo")
assert(!isCometEnabled(conf))
assert(!isCometLoaded(conf))

System.setProperty("os.name", oldProperty)

conf.setConf(SQLConf.PARQUET_INT96_TIMESTAMP_CONVERSION, true)
assert(!isCometEnabled(conf))
assert(!isCometLoaded(conf))

// Restore the original state
NativeBase.setLoaded(true)
Expand Down
Loading