Jefffrey commented on code in PR #19296:
URL: https://github.com/apache/datafusion/pull/19296#discussion_r2614219672
##########
datafusion/sqllogictest/test_files/timestamps.slt:
##########
@@ -2867,48 +2871,71 @@ select make_date(t.year, t.month, t.day) from
table_strings t;
statement ok
insert into table_strings values (2024, null, 23);
-query error DataFusion error: Execution error: Unable to parse date from 2024,
0, 23
+query D
select make_date(t.year, t.month, t.day) from table_strings t;
+----
+2024-01-23
+2023-11-30
+NULL
statement ok
drop table table_strings;
-query error DataFusion error: Execution error: Unable to parse date from 2024,
13, 23
+query error DataFusion error: Execution error: Month value '13' is out of range
select make_date(2024, 13, 23);
-query error DataFusion error: Execution error: Unable to parse date from 2024,
1, 32
-select make_date(2024, 01, 32);
+query error DataFusion error: Execution error: Day value '32' is out of range
+select make_date(2024, 1, 32);
-query error DataFusion error: Execution error: Unable to parse date from 2024,
0, 23
+query error DataFusion error: Execution error: Month value '0' is out of range
select make_date(2024, 0, 23);
query error DataFusion error: Execution error: Month value '\-1' is out of
range
select make_date(2024, -1, 23);
-query error DataFusion error: Execution error: Unable to parse date from 2024,
12, 0
+query error DataFusion error: Execution error: Day value '0' is out of range
select make_date(2024, 12, 0);
-query error DataFusion error: Execution error: Day value '\-1' is out of range
+query error DataFusion error: Execution error: Month value '13' is out of range
select make_date(2024, 13, -1);
-query error DataFusion error: Execution error: Unable to parse date from
null/empty value
+query D
select make_date(null, 1, 23);
+----
+NULL
-query error DataFusion error: Arrow error: Cast error: Cannot cast string ''
to value of Int32 type
+query error Cast error: Cannot cast string '' to value of Int32 type
select make_date('', 1, 23);
-query error DataFusion error: Execution error: Unable to parse date from
null/empty value
+query D
select make_date(2024, null, 23);
+----
+NULL
Review Comment:
This seemed quite odd since we had an explicit branch to handle null inputs:
https://github.com/apache/datafusion/blob/10c933cc76609e2c916f08853b57361c72684d3a/datafusion/functions/src/datetime/make_date.rs#L125-L130
It seems since the inputs were always cast away from `DataType::Null` the
branch above was never reached. Fixed the behaviour to output null in case any
input is null now.
##########
datafusion/functions/src/datetime/make_date.rs:
##########
@@ -225,180 +205,3 @@ fn make_date_inner<F: FnMut(i32)>(
exec_err!("Unable to parse date from {year}, {month}, {day}")
}
}
-
-#[cfg(test)]
-mod tests {
Review Comment:
Moved some to SLTs, removed the rest as redundant & already covered by SLTs
--
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]