Skip to content

fix: reject nested arrays in array_distance - #23995

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

fix: reject nested arrays in array_distance#23995
2010YOUY01 wants to merge 1 commit 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

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.77%. Comparing base (68d5874) to head (d84150a).
⚠️ Report is 12 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.77%   +0.02%     
==========================================
  Files        1096     1096              
  Lines      373282   373757     +475     
  Branches   373282   373757     +475     
==========================================
+ Hits       301440   301901     +461     
+ Misses      53869    53849      -20     
- Partials    17973    18007      +34     

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

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

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants