Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Apr 23, 2024
1 parent 92029ba commit 85c646c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/src/execution/datafusion/expressions/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ fn cast_string_to_integral_with_range_check(
}
}

/// We support parsing strings to i32 and i64 to match Spark's logic. Support for i8 and i16 is
/// implemented by first parsing as i32 and then downcasting. The CastStringToIntegral trait is
/// introduced so that we can have the parsing logic delegate either to an i32 or i64 accumulator
/// and avoid the need to use macros here.
trait CastStringToIntegral {
fn accumulate(
&mut self,
Expand Down Expand Up @@ -422,10 +426,7 @@ fn do_cast_string_to_int(
eval_mode: EvalMode,
type_name: &str,
) -> CometResult<()> {

// TODO avoid building a vec of chars
let chars: Vec<char> = str.chars().collect();

let mut i = 0;
let mut end = chars.len();

Expand All @@ -435,7 +436,7 @@ fn do_cast_string_to_int(
}

// skip trailing whitespace
while end > i && chars[end-1].is_whitespace() {
while end > i && chars[end - 1].is_whitespace() {
end -= 1;
}

Expand Down

0 comments on commit 85c646c

Please sign in to comment.