junjunjd commented on code in PR #7901:
URL: https://github.com/apache/arrow-datafusion/pull/7901#discussion_r1378462091
##########
datafusion/common/src/scalar.rs:
##########
@@ -1611,15 +1650,19 @@ impl ScalarValue {
Ok(array)
}
- fn iter_to_null_array(scalars: impl IntoIterator<Item = ScalarValue>) ->
ArrayRef {
- let length =
- scalars
- .into_iter()
- .fold(0usize, |r, element: ScalarValue| match element {
- ScalarValue::Null => r + 1,
- _ => unreachable!(),
- });
- new_null_array(&DataType::Null, length)
+ fn iter_to_null_array(
+ scalars: impl IntoIterator<Item = ScalarValue>,
+ ) -> Result<ArrayRef> {
+ let length = scalars.into_iter().try_fold(
+ 0usize,
+ |r, element: ScalarValue| match element {
+ ScalarValue::Null => Ok::<usize, DataFusionError>(r + 1),
+ s => {
+ _internal_err!("Expected ScalarValue::Null element.
Received {s:?}")
Review Comment:
Similar to the previous
[comment](https://github.com/apache/arrow-datafusion/pull/7901/files#r1378446881)
I made to the `build_*` macros in iter_to_array, this error is reachable.
Returning an internal error here aligns with the rest of the function.
This does not require any code change in client side, since
[iter_to_array](url) already returns a Result.
##########
datafusion/common/src/scalar.rs:
##########
@@ -1611,15 +1650,19 @@ impl ScalarValue {
Ok(array)
}
- fn iter_to_null_array(scalars: impl IntoIterator<Item = ScalarValue>) ->
ArrayRef {
- let length =
- scalars
- .into_iter()
- .fold(0usize, |r, element: ScalarValue| match element {
- ScalarValue::Null => r + 1,
- _ => unreachable!(),
- });
- new_null_array(&DataType::Null, length)
+ fn iter_to_null_array(
+ scalars: impl IntoIterator<Item = ScalarValue>,
+ ) -> Result<ArrayRef> {
+ let length = scalars.into_iter().try_fold(
+ 0usize,
+ |r, element: ScalarValue| match element {
+ ScalarValue::Null => Ok::<usize, DataFusionError>(r + 1),
+ s => {
+ _internal_err!("Expected ScalarValue::Null element.
Received {s:?}")
Review Comment:
Similar to the previous
[comment](https://github.com/apache/arrow-datafusion/pull/7901/files#r1378446881)
I made to the `build_*` macros in `iter_to_array`, this error is reachable.
Returning an internal error here aligns with the rest of the function.
This does not require any code change in client side, since
[iter_to_array](url) already returns a Result.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]