feat: add coverage threshold to skip Comet for low-coverage queries#3816
Draft
andygrove wants to merge 3 commits intoapache:mainfrom
Draft
feat: add coverage threshold to skip Comet for low-coverage queries#3816andygrove wants to merge 3 commits intoapache:mainfrom
andygrove wants to merge 3 commits intoapache:mainfrom
Conversation
Add spark.comet.exec.coverageThreshold config (0.0-1.0, default 0.0) that reverts to the original Spark plan when the fraction of converted operators falls below the threshold. This avoids the overhead of Spark-to-Comet transitions for queries where only a small percentage of operators can run natively.
Extract classifyNode() to eliminate duplicated match logic between generateTreeString and collectStats. Replace coveragePercent with coverageFraction (0.0-1.0) to match the threshold config units and avoid unnecessary multiply/divide conversions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #833
Rationale for this change
When Comet can only convert a small fraction of a query's operators, the overhead from Spark-to-Comet transitions can outweigh the benefit of native execution. This adds a simple cost-based mechanism to skip Comet entirely for such queries.
What changes are included in this PR?
spark.comet.exec.coverageThresholdconfig (double, 0.0–1.0, default 0.0 = disabled). When set, Comet falls back to the original Spark plan if the percentage of converted operators is below the threshold.CometCoverageStats.fromPlan()to compute coverage stats from aSparkPlanwithout building the explain string, reusable by both the explain output and the threshold check.CometExecRule._apply()that logs a warning and returns the original plan when coverage is insufficient.How are these changes tested?
Default behavior is unchanged (threshold = 0.0 disables the check). Manual verification that compile succeeds. Tests to be added.