You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "1fanwang (via GitHub)" <gi...@apache.org> on 2026/09/10 23:12:17 UTC
[PR] fix: report a negative array_resize size as a user error [datafusion]
1fanwang opened a new pull request, #25179:
URL: https://github.com/apache/datafusion/pull/25179
## Which issue does this PR close?
None; found by sweeping the scalar functions with edge-case arguments.
## Rationale for this change
`array_resize` with a negative size raises an internal error, which tells the
caller they hit a DataFusion bug and asks them to open a report:
```console
> SELECT array_resize(make_array(1,2,3), -1, 0);
Internal error: array_resize: failed to convert size to usize.
This issue was likely caused by a bug in DataFusion's code. Please help us to
resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues
```
The size is an argument to the query, so a negative value is the caller's input
rather than a broken internal invariant. Sending someone to the issue tracker
for their own argument is misleading, and it hides what was actually wrong.
The behaviour was already meant to be an error. `array_resize.slt` has expected
this call to fail since before this change, but with a bare `query error`, so
the internal error satisfied it and went unnoticed.
## What changes are included in this PR?
Reject a negative size with an execution error naming the value, which matches
how the neighbouring maximum-size check already reports bad input:
```console
> SELECT array_resize(make_array(1,2,3), -1, 0);
Execution error: array_resize: size must not be negative, got -1
```
Valid input is untouched: `0` still returns `[]`, `5` still grows to
`[1, 2, 3, 9, 9]`, and a NULL size still returns NULL.
## Are these changes tested?
Yes. The slt file gains the negative case for both `List` and `LargeList`, plus
`i64::MIN` for the boundary, each pinned to the new message so a regression back
to an internal error fails the suite.
```console
$ cargo test -p datafusion-sqllogictest --test sqllogictests -- array
Progress: 53/53 files completed (100%)
$ cargo test -p datafusion-functions-nested --lib resize
test result: ok. 4 passed; 0 failed
```
The pre-existing `query error` case for `-5` still passes, so the contract that
a negative size fails is unchanged.
## Are there any user-facing changes?
The error for a negative size changes from an internal error to an execution
error with a clear message. No valid call changes behaviour, and no API changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: report a negative array_resize size as a user error [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #25179:
URL: https://github.com/apache/datafusion/pull/25179
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: report a negative array_resize size as a user error [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #25179:
URL: https://github.com/apache/datafusion/pull/25179#issuecomment-5626932717
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/25179?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `87.50000%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 81.91%. Comparing base ([`7e5f40a`](https://app.codecov.io/gh/apache/datafusion/commit/7e5f40a69aae9199c3c682806750e40d6bebb398?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f25bf2e`](https://app.codecov.io/gh/apache/datafusion/commit/f25bf2e51669ae939a0f528b57af81baab00375c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/datafusion/pull/25179?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [datafusion/functions-nested/src/resize.rs](https://app.codecov.io/gh/apache/datafusion/pull/25179?src=pr&el=tree&filepath=datafusion%2Ffunctions-nested%2Fsrc%2Fresize.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9mdW5jdGlvbnMtbmVzdGVkL3NyYy9yZXNpemUucnM=) | 87.50% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25179?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #25179 +/- ##
==========================================
- Coverage 81.91% 81.91% -0.01%
==========================================
Files 1132 1132
Lines 421117 421119 +2
Branches 421117 421119 +2
==========================================
- Hits 344961 344952 -9
- Misses 55767 55775 +8
- Partials 20389 20392 +3
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/25179?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: report a negative array_resize size as a user error [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #25179:
URL: https://github.com/apache/datafusion/pull/25179#issuecomment-5675168348
thanks @1fanwang & @nuno-faria
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: report a negative array_resize size as a user error [datafusion]
Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on code in PR #25179:
URL: https://github.com/apache/datafusion/pull/25179#discussion_r3993218968
##########
datafusion/functions-nested/src/resize.rs:
##########
@@ -186,6 +188,16 @@ fn array_resize_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {
}
}
+/// Resolve the requested size for one row. A negative size is rejected as a
+/// user error; reporting it as an internal error asks the caller to file a bug
+/// report for input they control.
+fn resize_count(count_array: &Int64Array, idx: usize) -> Result<usize> {
Review Comment:
Done in https://github.com/apache/datafusion/commit/847b155277d6dfa630b78310aa7407060e968be3.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: report a negative array_resize size as a user error [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on code in PR #25179:
URL: https://github.com/apache/datafusion/pull/25179#discussion_r3992661690
##########
datafusion/functions-nested/src/resize.rs:
##########
@@ -186,6 +188,16 @@ fn array_resize_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {
}
}
+/// Resolve the requested size for one row. A negative size is rejected as a
+/// user error; reporting it as an internal error asks the caller to file a bug
+/// report for input they control.
+fn resize_count(count_array: &Int64Array, idx: usize) -> Result<usize> {
Review Comment:
I don't think it's necessary to document the past behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org