jayzhan211 commented on code in PR #12308:
URL: https://github.com/apache/datafusion/pull/12308#discussion_r1751121119
##########
datafusion/sqllogictest/test_files/select.slt:
##########
@@ -483,6 +483,17 @@ CREATE TABLE foo2(c1 double, c2 double) AS VALUES
(2, 5),
(3, 6);
+statement ok
+SELECT COALESCE(column1, column2) FROM VALUES (null, 1.2);
Review Comment:
Maybe add `SELECT arrow_typeof(COALESCE(column1, column2)) FROM VALUES
(null, 1.2);` to show that the final coerced type?
##########
datafusion/sqllogictest/test_files/select.slt:
##########
@@ -483,6 +483,17 @@ CREATE TABLE foo2(c1 double, c2 double) AS VALUES
(2, 5),
(3, 6);
+statement ok
+SELECT COALESCE(column1, column2) FROM VALUES (null, 1.2);
+
+# multiple rows and columns with null need type coercion
+statement ok
+SELECT column1, column2, column3 FROM VALUES
Review Comment:
We can try subquery to show the type
`select * from (select * from values (...))`
##########
datafusion/functions/src/datetime/to_local_time.rs:
##########
@@ -348,6 +327,25 @@ impl ScalarUDFImpl for ToLocalTimeFunc {
self.to_local_time(args)
}
+
+ fn coerce_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
+ if arg_types.len() != 1 {
+ return Err(DataFusionError::Execution(format!(
+ "to_local_time function requires 1 argument, got {:?}",
+ arg_types.len()
+ )));
+ }
+
+ match &arg_types[0] {
+ Timestamp(Nanosecond, timezone) => Ok(vec![Timestamp(Nanosecond,
timezone.clone())]),
+ Timestamp(Microsecond, timezone) => Ok(vec![Timestamp(Microsecond,
timezone.clone())]),
+ Timestamp(Millisecond, timezone) => Ok(vec![Timestamp(Millisecond,
timezone.clone())]),
+ Timestamp(Second, timezone) => Ok(vec![Timestamp(Second,
timezone.clone())]),
+ _ => Err(DataFusionError::Execution(format!(
Review Comment:
You could use `macro` like `exec_err`, `plan_err`
--
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]