Skip to content

fix: reject nested arrays in array_distance - #23995

Open
2010YOUY01 wants to merge 3 commits into
apache:mainfrom
2010YOUY01:codex/fix-array-distance-1d
Open

fix: reject nested arrays in array_distance#23995
2010YOUY01 wants to merge 3 commits into
apache:mainfrom
2010YOUY01:codex/fix-array-distance-1d

Conversation

@2010YOUY01

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • Closes #.

Rationale for this change

See reproducer in datafusion-cli, now array_distance() allows nested list as input, and it will use the 1st inner array to compute the distance.

> select array_distance([[1, 2], [100, 100]], [[1, 4], [0, 0]]);
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| array_distance(make_array(make_array(Int64(1),Int64(2)),make_array(Int64(100),Int64(100))),make_array(make_array(Int64(1),Int64(4)),make_array(Int64(0),Int64(0)))) |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 2.0                                                                                                                                                                 |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.000 seconds.

This look like an invalid input, this PR reject nested array in this function

What changes are included in this PR?

At function planning, reject array_distance with nested array input args

Are these changes tested?

Yes, slt (plus some extra tests that I found that has not been covered in codecov)

Are there any user-facing changes?

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Jul 30, 2026
@codecov-commenter

codecov-commenter commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.53846% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.85%. Comparing base (68d5874) to head (db5e7d7).
⚠️ Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/functions-nested/src/distance.rs 61.53% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23995      +/-   ##
==========================================
+ Coverage   80.75%   80.85%   +0.10%     
==========================================
  Files        1096     1099       +3     
  Lines      373282   374292    +1010     
  Branches   373282   374292    +1010     
==========================================
+ Hits       301440   302640    +1200     
+ Misses      53869    53596     -273     
- Partials    17973    18056      +83     

☔ 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.

@nuno-faria nuno-faria left a comment

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.

Thanks @2010YOUY01, I think it makes sense to only support 1D arrays. I think its better to add a note to the upgrade guide though.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 31, 2026
@2010YOUY01

Copy link
Copy Markdown
Contributor Author

Thanks @2010YOUY01, I think it makes sense to only support 1D arrays. I think its better to add a note to the upgrade guide though.

Thank you for the review, I have updated the upgrade guide.

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

Labels

documentation Improvements or additions to documentation functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants