fix: return null from regexp_extract for an invalid pattern when every subject row is null #7736
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
comphead
Which issue does this PR close?
Closes #7711.
Rationale for this change
Spark compiles the pattern of
regexp_extractandregexp_extract_allonly 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_argsinregexp_extract_common.rsnow returnsParsedArgs::NullResultbefore compiling the pattern when the subject is aUtf8/LargeUtf8array 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?
regexp_extract.rsandregexp_extract_all.rs: all-nullUtf8andLargeUtf8arrays and a null scalar return null with an invalid pattern; an array with one non-null row still errors.regexp_extract_enabled.sqlandregexp_extract_all_enabled.sql: an all-null table with an invalid pattern and with a lookahead pattern, and aWHERE s IS NULLfilter over the existing table, all checked against Spark withexpect_native.The new tests fail without the fix.