Skip to content

Commit

Permalink
Minor: Use execution error in ScalarValue::iter_to_array for incorrec…
Browse files Browse the repository at this point in the history
…t usage (apache#11999)

* fix error

Signed-off-by: jayzhan211 <[email protected]>

* use exec err

Signed-off-by: jayzhan211 <[email protected]>

* fmt

Signed-off-by: jayzhan211 <[email protected]>

---------

Signed-off-by: jayzhan211 <[email protected]>
  • Loading branch information
jayzhan211 authored Aug 16, 2024
1 parent 9d1cf74 commit 9f77021
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::cast::{
as_decimal128_array, as_decimal256_array, as_dictionary_array,
as_fixed_size_binary_array, as_fixed_size_list_array,
};
use crate::error::{DataFusionError, Result, _internal_err, _not_impl_err};
use crate::error::{DataFusionError, Result, _exec_err, _internal_err, _not_impl_err};
use crate::hash_utils::create_hashes;
use crate::utils::{
array_into_fixed_size_list_array, array_into_large_list_array, array_into_list_array,
Expand Down Expand Up @@ -1707,9 +1707,7 @@ impl ScalarValue {
// figure out the type based on the first element
let data_type = match scalars.peek() {
None => {
return _internal_err!(
"Empty iterator passed to ScalarValue::iter_to_array"
);
return _exec_err!("Empty iterator passed to ScalarValue::iter_to_array");
}
Some(sv) => sv.data_type(),
};
Expand All @@ -1723,7 +1721,7 @@ impl ScalarValue {
if let ScalarValue::$SCALAR_TY(v) = sv {
Ok(v)
} else {
_internal_err!(
_exec_err!(
"Inconsistent types in ScalarValue::iter_to_array. \
Expected {:?}, got {:?}",
data_type, sv
Expand All @@ -1743,7 +1741,7 @@ impl ScalarValue {
if let ScalarValue::$SCALAR_TY(v, _) = sv {
Ok(v)
} else {
_internal_err!(
_exec_err!(
"Inconsistent types in ScalarValue::iter_to_array. \
Expected {:?}, got {:?}",
data_type, sv
Expand All @@ -1765,7 +1763,7 @@ impl ScalarValue {
if let ScalarValue::$SCALAR_TY(v) = sv {
Ok(v)
} else {
_internal_err!(
_exec_err!(
"Inconsistent types in ScalarValue::iter_to_array. \
Expected {:?}, got {:?}",
data_type, sv
Expand Down Expand Up @@ -1908,11 +1906,11 @@ impl ScalarValue {
if &inner_key_type == key_type {
Ok(*scalar)
} else {
_internal_err!("Expected inner key type of {key_type} but found: {inner_key_type}, value was ({scalar:?})")
_exec_err!("Expected inner key type of {key_type} but found: {inner_key_type}, value was ({scalar:?})")
}
}
_ => {
_internal_err!(
_exec_err!(
"Expected scalar of type {value_type} but found: {scalar} {scalar:?}"
)
}
Expand Down Expand Up @@ -1940,7 +1938,7 @@ impl ScalarValue {
if let ScalarValue::FixedSizeBinary(_, v) = sv {
Ok(v)
} else {
_internal_err!(
_exec_err!(
"Inconsistent types in ScalarValue::iter_to_array. \
Expected {data_type:?}, got {sv:?}"
)
Expand All @@ -1965,7 +1963,7 @@ impl ScalarValue {
| DataType::RunEndEncoded(_, _)
| DataType::ListView(_)
| DataType::LargeListView(_) => {
return _internal_err!(
return _not_impl_err!(
"Unsupported creation of {:?} array from ScalarValue {:?}",
data_type,
scalars.peek()
Expand Down

0 comments on commit 9f77021

Please sign in to comment.