Skip to content

feat: support ansi for elt - #23928

Open
comphead wants to merge 1 commit into
apache:mainfrom
comphead:elt_ansi
Open

feat: support ansi for elt#23928
comphead wants to merge 1 commit into
apache:mainfrom
comphead:elt_ansi

Conversation

@comphead

@comphead comphead commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Part of #23929

Rationale for this change

Spark's elt errors on out-of-range indices when ANSI is on, and returns NULL when off. DataFusion previously always returned NULL (there was a TODO for this in the source).

What changes are included in this PR?

  • elt.rs: read enable_ansi_mode from ScalarFunctionArgs::config_options; raise "The index N is out of bounds. The array has M elements." in ANSI mode, keep NULL behavior otherwise. NULL index
    always returns NULL.
  • elt.slt: add missing ANSI-off cases (index 0, negative, large, NULL index, NULL value, vectorized) and a full ANSI-on section with statement error assertions.

Are these changes tested?

Yes. New Rust unit tests and sqllogictest cases cover both modes.

Are there any user-facing changes?

With enable_ansi_mode = true, elt on invalid indices now errors instead of returning NULL. Default behavior unchanged. No API changes.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.20290% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.67%. Comparing base (2028927) to head (61ea765).

Files with missing lines Patch % Lines
datafusion/spark/src/function/string/elt.rs 94.20% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23928      +/-   ##
==========================================
- Coverage   80.67%   80.67%   -0.01%     
==========================================
  Files        1095     1095              
  Lines      372490   372542      +52     
  Branches   372490   372542      +52     
==========================================
+ Hits       300517   300557      +40     
- Misses      54035    54042       +7     
- Partials    17938    17943       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

#[test]
fn elt_ansi_valid_indices_ok() -> Result<()> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need these tests if theyre already covered by slts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spark sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants