harshchawra commented on code in PR #19340:
URL: https://github.com/apache/datafusion/pull/19340#discussion_r2627172999
##########
datafusion/spark/src/function/datetime/next_day.rs:
##########
@@ -191,57 +214,151 @@ where
let result = date_array
.iter()
.zip(day_of_week_array.iter())
- .map(|(days, day_of_week)| {
- if let Some(days) = days {
- if let Some(day_of_week) = day_of_week {
- spark_next_day(days, day_of_week)
- } else {
- // TODO: if spark.sql.ansi.enabled is false,
- // returns NULL instead of an error for a malformed
dayOfWeek.
- None
- }
- } else {
- None
- }
+ .map(|(days, day_of_week)| match (days, day_of_week) {
+ (Some(days), Some(day_of_week)) => spark_next_day(days,
day_of_week),
+ _ => None,
})
.collect::<Date32Array>();
+
Ok(Arc::new(result) as ArrayRef)
}
fn spark_next_day(days: i32, day_of_week: &str) -> Option<i32> {
let date = Date32Type::to_naive_date(days);
- let day_of_week = day_of_week.trim().to_uppercase();
- let day_of_week = match day_of_week.as_str() {
- "MO" | "MON" | "MONDAY" => Some("MONDAY"),
- "TU" | "TUE" | "TUESDAY" => Some("TUESDAY"),
- "WE" | "WED" | "WEDNESDAY" => Some("WEDNESDAY"),
- "TH" | "THU" | "THURSDAY" => Some("THURSDAY"),
- "FR" | "FRI" | "FRIDAY" => Some("FRIDAY"),
- "SA" | "SAT" | "SATURDAY" => Some("SATURDAY"),
- "SU" | "SUN" | "SUNDAY" => Some("SUNDAY"),
- _ => {
- // TODO: if spark.sql.ansi.enabled is false,
- // returns NULL instead of an error for a malformed dayOfWeek.
- None
- }
+ let day_of_week = match day_of_week.trim().to_uppercase().as_str() {
Review Comment:
Updated implementation to use `eq_ignore_ascii_case()`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]