Skip to content

Commit

Permalink
remove macro for date parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vidyasankarv committed May 8, 2024
1 parent e6cf005 commit 646274c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/src/execution/datafusion/expressions/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,20 @@ impl Cast {

let cast_array: ArrayRef = match to_type {
DataType::Date32 | DataType::Date64 => {
cast_utf8_to_date!(string_array, eval_mode, Date32Type, date_parser)
let len = string_array.len();
let mut cast_array = PrimitiveArray::<Date32Type>::builder(len);
for i in 0..len {
if string_array.is_null(i) {
cast_array.append_null()
} else if let Ok(Some(cast_value)) =
date_parser(string_array.value(i).trim(), eval_mode)
{
cast_array.append_value(cast_value);
} else {
cast_array.append_null()
}
}
Arc::new(cast_array.finish()) as ArrayRef
}
_ => unreachable!("Invalid data type {:?} in cast from string", to_type),
};
Expand Down

0 comments on commit 646274c

Please sign in to comment.