feat: add Spark-compatible array_position #63
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 354 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.351
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #63"
general
weight: 0.35
kosiew
Closes #220.
Summary
Ports
array_positionfrom Comet (native/spark-expr/src/array_funcs/array_position.rs).BIGINT,0when not found, andNULLwhen the array or the element isNULL. DataFusion's built-in returnsUInt64, returnsNULLwhen the element is not found, and matches aNULLelement against the firstNULLin the array.NULLelements inside the array never match but still count toward the position.NaN = NaNand-0.0 = 0.0.NULLnested inside compared values equalsNULL.ListandLargeList(fixed-size lists are coerced toList).findTightestCommonTypein a customcoerce_types: numbers widen, an integer widens to a decimal only if the decimal holds all its values, and a date widens to a timestamp. Everything else fails at planning time with Spark's error classes:-
ARRAY_FUNCTION_DIFF_TYPES: string and number (either way), two different decimals, decimal and double, struct fields with different names, order or types.-
NULL_TYPE: aNULL-typed array, or a common type ofNULL(array_position(array(), NULL)).-
UNEXPECTED_INPUT_TYPE: a non-array first argument.-
INVALID_ORDERING_TYPE: map elements at any depth.Comparison uses arrow's
make_comparatorafter canonicalizing NaN and-0.0withnormalize_array. That helper and the rest of the float normalization fromarray_containsnow live in a sharedarray/float_normalize.rsmodule used by both functions; it also descends into maps now, sincearray_containsstill accepts map elements.Known differences from Spark, both covered by tests:
coerce_typescannot see the session config.Documents the function with
#[user_doc], following the guidelines inCONTRIBUTING.md.Testing
array/array_position.slt(93 queries, 24 of themquery errorwith message regexes). Expected values were checked againstpyspark==4.2.0with the PySpark SLT runner: all records match except the two known differences above and thearray(1, NULL)[1]query, where arrays here are 1-based and Spark's are 0-based (commented in the file).cargo clippy --all-targets --all-features -- -D warnings: cleancargo test -p datafusion-spark: passcargo test -p datafusion-spark-sqllogictest: 246/246 files passNot done: the full Spark source audit across 3.5/4.0/4.1.
🤖 Generated with Claude Code