← Back to Pull requests

fix: return null from regexp_extract for an invalid pattern when every subject row is null #7736

Open
unknown opened this pull request with 179 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 21, 2026 16:01 UTC
Author

Which issue does this PR close?

Closes #7711.

Rationale for this change

Spark compiles the pattern of regexp_extract and regexp_extract_all only on a row whose subject is non-null. When every subject row is null it returns null and never looks at the pattern. The native implementation compiled the pattern before looking at the subject, so an invalid pattern (or one that only Rust regex rejects, such as a lookahead) raised an error on input where Spark returns null.

What changes are included in this PR?

parse_args in regexp_extract_common.rs now returns ParsedArgs::NullResult before compiling the pattern when the subject is a Utf8/LargeUtf8 array whose rows are all null, or a null string scalar. Both functions share this path. A subject with at least one non-null row still reports the invalid pattern, and other subject types are still reported as unsupported.

How are these changes tested?

  • Unit tests in regexp_extract.rs and regexp_extract_all.rs: all-null Utf8 and LargeUtf8 arrays and a null scalar return null with an invalid pattern; an array with one non-null row still errors.

  • SQL file tests in regexp_extract_enabled.sql and regexp_extract_all_enabled.sql: an all-null table with an invalid pattern and with a lookahead pattern, and a WHERE s IS NULL filter over the existing table, all checked against Spark with expect_native.
  • The new tests fail without the fix.

    Diff: 179 lines (+134 / -45) across 2 files Reviewer: comphead Review duration: 13342m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 179 lines diff across 2 files
    0.36
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.311
    Real PR Conversation Timeline
    1 comments
    "Review active on #7736"
    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: 35.5% (MEDIUM) · Higher = larger blast radius
    35.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: 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: 18.9% · Safe to merge
    18.9%