adriangb commented on code in PR #25173:
URL: https://github.com/apache/datafusion/pull/25173#discussion_r4020077476


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -673,38 +735,42 @@ impl GenerateSeriesFuncImpl {
             );
         }
 
-        // Parse start timestamp
-        let (start_ts, tz) = match &exprs[0] {
-            Expr::Literal(ScalarValue::TimestampNanosecond(ts, tz), _) => {
-                (*ts, tz.clone())
-            }
-            other => {
-                return plan_err!(
-                    "First argument must be a timestamp or NULL, got {:?}",
-                    other
-                );
-            }
-        };
-
-        // Parse end timestamp
-        let end_ts = match &exprs[1] {
-            Expr::Literal(ScalarValue::Null, _) => None,
-            Expr::Literal(ScalarValue::TimestampNanosecond(ts, _), _) => *ts,
-            other => {
-                return plan_err!(
-                    "Second argument must be a timestamp or NULL, got {:?}",
-                    other
-                );
-            }
-        };
+        // Parse the start and end timestamps.
+        //
+        // Both are widened to nanoseconds, so the two arguments do not have to
+        // agree on a `TimeUnit`: an Arrow timestamp denotes an instant
+        // regardless of the unit it happens to be stored in, and the output is
+        // nanoseconds either way (see the schema below).
+        let (start_ts, tz) =
+            timestamp_arg_to_nanos(&exprs[0], "First argument", self.name)?;
+        let (end_ts, _end_tz) =
+            timestamp_arg_to_nanos(&exprs[1], "Second argument", self.name)?;
+
+        // `_end_tz` is deliberately discarded: the output timezone comes from

Review Comment:
   Right, no behavior change. I shortened the comment.



-- 
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]

Reply via email to