← Back to Pull requests

refactor: parse Spark versions in Comet instead of calling Spark's private VersionUtils #7404

Open
unknown opened this pull request with 319 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 02, 2026 16:06 UTC
Author

Which issue does this PR close?

Part of #7241. That issue asks for the patch-release version checks to share one parser and one
home (SparkFixes). This PR does the parser half: Comet now has one version parser, in
Utils.majorMinorPatchVersion, and it no longer calls Spark's VersionUtils. Moving the checks
themselves into SparkFixes is left for the rest of #7241.

Rationale for this change

org.apache.spark.util.VersionUtils is private[spark]. Comet reaches it from
org.apache.spark.sql.comet.util.Utils, which compiles only because that object sits in a
org.apache.spark package, and vendor builds of Spark have changed the method's signature
(Cloudera's returns a 4-tuple with the vendor suffix), so Comet fails to link against them.
Separately, RegrSparkVersions carried its own regex because it predates the helper, so two
parsers read the same SPARK_VERSION string with different rules.

What changes are included in this PR?

  • Utils.majorMinorPatchVersion applies Spark's own VersionUtils.majorMinorPatchVersion regex

  • itself: ^(\d+)(?:\.(\d+)(?:\.(\d+)(?:[.-].*)?)?)?$. A missing minor or patch reads as 0,
    and anything after the patch that starts with . or - (-SNAPSHOT, -amzn-1, a vendor
    build number such as .7.3.2.30000-15) is ignored, exactly as Spark does. Strings Spark would
    reject (v3.5.9, 3.5.8x) still return None.
  • The Spark 3.5 ShimCometScanExec.isSparkVersionAtLeast355 calls Utils instead of

  • VersionUtils directly, and drops the VersionUtils import.
  • RegrSparkVersions.majorMinorPatch calls Utils.majorMinorPatchVersion and loses its private

  • regex. Its fallback to the minor-version rule for an unparseable string is unchanged. The one
    behavioural difference is for a string such as 4.0.5_vendor: the old regex read it as
    (4, 0, 5), Spark's regex does not, so the regression checks now take the same fallback the
    other checks already took for it.

    How are these changes tested?

    A new UtilsSuite test, majorMinorPatchVersion parses Spark version strings like Spark's
    VersionUtils
    , pins ten inputs to what Spark's VersionUtils returns for them: plain releases,
    -SNAPSHOT, an Amazon suffix, a Cloudera build number, 3.5 and 3 alone, and the malformed
    3.5.8x, v3.5.9 and the empty string.

    The existing CometAggregateSuite rows for RegrSparkVersions, including the v3.5.9 fallback
    pin, and the Spark 3.5 scan shim's use of the helper cover the two call sites.

    🤖 Generated with Claude Code

    Diff: 319 lines (+239 / -80) across 3 files Reviewer: comphead Review duration: 3339m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 319 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #7404"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.6% · Safe to merge
    21.6%