← Back to Pull requests

[SPARK-62434] Remove unnecessary comments and express their intent in code #630

Closed
unknown closed this pull request without merging on Nov 30, 2026 21:37 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 00:25 UTC
Author

What changes were proposed in this pull request?

This PR aims to remove unnecessary comments from the hand-written sources of the SparkConnect module and to express the intent of some of them in code instead.

1. Remove comments which narrate or duplicate the code: // MARK: banners, file-level prose blocks, section labels, a TODO, a commented-out line of code, and /// doc comments on non-public symbols. Generated sources (.pb.swift, base.grpc.swift, _generated.swift) and the vendored Apache Arrow sources are not touched.
2. Keep the license headers, the doc comments of public APIs, and the comments which state what the code cannot express, e.g., security constraints, concurrency invariants, and server-side contracts.
3. Express the intent of the removed comments in code.
- DataFrame.rdd() and SparkSession.sparkContext throw SparkConnectError.unsupportedOperation with the error class and SQLSTATE, which were written only in the comments. The doc comments of errorClass and sqlState are updated because they are no longer provided only by the server.
- SparkConnectClient parses and validates the session_id parameter of the connection string like the other parameters, and SparkSession uses it instead of a separate regex. The Scala client also parses it in SparkConnectClient.Builder.
- Apache Spark 4.3.0 (2026-10-27) SparkConnectClient.Builder.parseURIParams
- Rename isOperationNotFound to isOperationOrSessionNotFound because it also matches INVALID_HANDLE.SESSION_NOT_FOUND, rename polynomial to ieee8023Polynomial in CRC32, and name the parity check hasOtherwise in Column.isChainableCaseWhen.

Why are the changes needed?

Comments which narrate the code drift from it over time, while the code itself can carry the same information. For example, rdd() threw an UnsupportedOperation error without any details although its comment described the error class and SQLSTATE. In addition, the session_id parameter was handled in two places: SparkConnectClient skipped it and SparkSession parsed it again with a regex.

Does this PR introduce _any_ user-facing change?

Yes, the following are minor user-facing changes compared to the latest release, 0.8.0 (2026-11-09).

  • DataFrame.rdd() and SparkSession.sparkContext throw errors with details. The existing call sites like catch SparkConnectError.UnsupportedOperation and #expect(throws: SparkConnectError.UnsupportedOperation) work as before because SparkConnectError equality compares only the cases.
  • do {
      try await spark.range(1).rdd()
    } catch SparkConnectError.unsupportedOperation(let details) {
      print(details.errorClass)  // BEFORE: nil, AFTER: Optional("UNSUPPORTED_CONNECT_FEATURE.RDD")
      print(details.sqlState)    // BEFORE: nil, AFTER: Optional("0A000")
    }
    

  • The session_id parameter of the connection string is handled like the other parameters.

  • - The key is case-insensitive. Previously, sc://localhost/;SESSION_ID=<uuid> was silently ignored and a random session ID was used.
    - When session_id is repeated, every value is validated and the last one is used like the Scala client. Previously, only the first one was validated and used.

    How was this patch tested?

    Pass the CIs with the updated test cases.

    Was this patch authored or co-authored using generative AI tooling?

    Generated-by: Claude Opus 5.5

    Diff: 456 lines (+342 / -114) across 5 files Reviewer: dongjoon-hyun Review duration: 2712m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 456 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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.366
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #630"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 19.7% · Safe to merge
    19.7%