Skip to content

Commit 2657b67

Browse files
author
B Vadlamani
committed
refactor_boolean_cast_ops_add_tests
1 parent 70ec5a7 commit 2657b67

2 files changed

Lines changed: 20 additions & 18 deletions

File tree

native/spark-expr/src/conversion_funcs/cast.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
use crate::conversion_funcs::boolean::can_cast_from_boolean;
19+
use crate::conversion_funcs::utils::{cast_overflow, invalid_value};
1920
use crate::conversion_funcs::utils::{is_identity_cast, spark_cast_postprocess};
2021
use crate::utils::array_with_timezone;
2122
use crate::{timezone, BinaryOutputStyle};
@@ -2547,24 +2548,6 @@ fn parse_decimal_str(
25472548
Ok((final_mantissa, final_scale))
25482549
}
25492550

2550-
#[inline]
2551-
fn invalid_value(value: &str, from_type: &str, to_type: &str) -> SparkError {
2552-
SparkError::CastInvalidValue {
2553-
value: value.to_string(),
2554-
from_type: from_type.to_string(),
2555-
to_type: to_type.to_string(),
2556-
}
2557-
}
2558-
2559-
#[inline]
2560-
fn cast_overflow(value: &str, from_type: &str, to_type: &str) -> SparkError {
2561-
SparkError::CastOverFlow {
2562-
value: value.to_string(),
2563-
from_type: from_type.to_string(),
2564-
to_type: to_type.to_string(),
2565-
}
2566-
}
2567-
25682551
impl Display for Cast {
25692552
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
25702553
write!(

native/spark-expr/src/conversion_funcs/utils.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use crate::SparkError;
1819
use arrow::array::{
1920
Array, ArrayRef, ArrowPrimitiveType, AsArray, GenericStringArray, PrimitiveArray,
2021
};
@@ -112,3 +113,21 @@ fn trim_end(s: &str) -> &str {
112113
pub fn is_identity_cast(from_type: &DataType, to_type: &DataType) -> bool {
113114
from_type == to_type
114115
}
116+
117+
#[inline]
118+
pub fn cast_overflow(value: &str, from_type: &str, to_type: &str) -> SparkError {
119+
SparkError::CastOverFlow {
120+
value: value.to_string(),
121+
from_type: from_type.to_string(),
122+
to_type: to_type.to_string(),
123+
}
124+
}
125+
126+
#[inline]
127+
pub fn invalid_value(value: &str, from_type: &str, to_type: &str) -> SparkError {
128+
SparkError::CastInvalidValue {
129+
value: value.to_string(),
130+
from_type: from_type.to_string(),
131+
to_type: to_type.to_string(),
132+
}
133+
}

0 commit comments

Comments
 (0)