Skip to content

Commit 5a7420e

Browse files
adriangbclaude
authored andcommitted
fix: accept all timestamp precisions in generate_series/range (apache#25173)
## Which issue does this PR close? - Closes apache#25169 ## Rationale for this change ### What a user hits Build a timestamp series from second-precision bounds. Second and millisecond precision are common in Parquet, so this is what a series over a column read from storage looks like. ```sql SELECT * FROM generate_series( arrow_cast(TIMESTAMP '2024-01-01 00:00:00', 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-03 00:00:00', 'Timestamp(Second, None)'), INTERVAL '1 day'); ``` On `main` the call fails, and the message says the argument is not a timestamp while it prints a timestamp: ``` Error: Error during planning: First argument must be a timestamp or NULL, got Literal(TimestampSecond(1704067200, None), None) ``` With this PR the same call works: ``` +---------------------+ | value | +---------------------+ | 2024-01-01T00:00:00 | | 2024-01-02T00:00:00 | | 2024-01-03T00:00:00 | +---------------------+ ``` ### What changes for a user `generate_series` and `range` accept all four timestamp precisions, not nanoseconds alone. The same query written with a second-precision or millisecond-precision bound now returns a series instead of an error. Queries that worked before keep working, and the result type does not change. Error messages also name the type they rejected, so a reader can act on them. ### The technical detail `generate_series` and `range` over timestamps accepted `Timestamp(Nanosecond, _)` alone. Any other `TimeUnit` failed. The dispatch in `call_with_args` already routed every `DataType::Timestamp(_, _)` into `call_timestamp`, and `call_timestamp` then hard-matched `ScalarValue::TimestampNanosecond`. So a coarser bound reached a match arm that could not accept it, and fell through to a message about the wrong thing. There is no design question about the result precision. The output schema is already fixed at `Timestamp(Nanosecond, tz)`, so the function already produced nanoseconds. It refused only coarser *inputs*. ### Field research Both reference engines accept coarser bounds, so this change moves DataFusion toward them. I measured both rather than quote their documentation. PostgreSQL 17.11 (`postgres:17`): ``` => SELECT pg_typeof(g), g FROM generate_series('2024-01-01'::timestamp(0), '2024-01-03'::timestamp(0), INTERVAL '1 day') g; pg_typeof | g -----------------------------+--------------------- timestamp without time zone | 2024-01-01 00:00:00 timestamp without time zone | 2024-01-02 00:00:00 timestamp without time zone | 2024-01-03 00:00:00 (3 rows) ``` Mixed precisions also work there: ``` => SELECT g FROM generate_series('2024-01-01'::timestamp(0), '2024-01-03'::timestamp(3), INTERVAL '1 day') g; -- 3 rows ``` DuckDB 1.5.2: ``` D SELECT * FROM generate_series(TIMESTAMP_S '2024-01-01', TIMESTAMP_S '2024-01-03', INTERVAL 1 DAY); -- 3 rows, type TIMESTAMP D SELECT * FROM generate_series(TIMESTAMP_MS '2024-01-01', TIMESTAMP_MS '2024-01-03', INTERVAL 1 DAY); -- 3 rows D SELECT * FROM generate_series(TIMESTAMP_NS '2024-01-01', TIMESTAMP_NS '2024-01-03', INTERVAL 1 DAY); -- 3 rows D SELECT * FROM range(TIMESTAMP_S '2024-01-01', TIMESTAMP_S '2024-01-03', INTERVAL 1 DAY); -- 2 rows D SELECT * FROM generate_series(TIMESTAMP_S '2024-01-01', TIMESTAMP_MS '2024-01-03', INTERVAL 1 DAY); -- 3 rows ``` Two points carry over from both engines: - Neither engine rejects a coarser bound. - Neither engine lets the bound's unit reach the result type. PostgreSQL returns `timestamp`, DuckDB returns `TIMESTAMP`, and this PR keeps `Timestamp(Nanosecond, tz)`. Neither engine can arbitrate the timezone question below. Both store a `timestamptz` as an instant with no per-value zone, so both render the series in the session zone. Arrow puts the zone in the value, so DataFusion must pick one, and no cross-engine comparison is meaningful there. ## What changes are included in this PR? Both timestamp bounds in `call_timestamp`, which `generate_series` and `range` share, go through a new `timestamp_arg_to_nanos` helper instead of a hard match on `ScalarValue::TimestampNanosecond`. - **All four `TimeUnit`s are accepted** and widened to nanoseconds. The output stays `Timestamp(Nanosecond, tz)`. - **Overflow is checked.** `Second`, `Millisecond` and `Microsecond` span far more than an `i64` of nanoseconds, which covers roughly 1677 to 2262. The widening is a `checked_mul`, so an out-of-range bound is a plan error that names the argument, the value and the window: ``` First argument for generate_series is out of range of nanosecond timestamps: 9223372036854775807 (Timestamp(Second, None)) is outside 1677-09-21T00:12:43.145224192 to 2262-04-11T23:47:16.854775807 ``` An unchecked multiply wraps in silence in a release build and emits a plausible but wrong series. No panic was reachable from SQL through this path before: `call_timestamp` did no arithmetic on the bounds, and the `DATE` overload already used `checked_mul`. The new multiplication is checked so that stays true now that coarser units get through. - **Mixed precisions work.** The two bounds are read independently, so `generate_series(ts_second, ts_micro, INTERVAL '1 day')` is fine. A timestamp denotes an instant whatever unit holds it, and both sides reach the same nanosecond scale before the comparison. - **Timezone handling does not change, but a comment now explains it.** The output timezone still comes from the start argument. Two different timezones on the two bounds are deliberately not an error: an Arrow timezone changes how an instant is rendered, not which instant it is. The start's zone is the one kept because it also anchors the calendar arithmetic that advances the series. Month and day steps apply in local time, so they follow that zone's DST rules. - **Error messages name the type they rejected** instead of a dump of the whole `Expr`, for example `Second argument for generate_series must be a TIMESTAMP or NULL constant, got Int64`. This covers the timestamp and `DATE` overloads. A non-literal argument gets the same message, with the expression after "got". Two limits stay, and both are worth a mention. - The step argument still accepts `Interval(MonthDayNano)` alone. That is not reachable as a limit from SQL, because `arrow_cast` to `Interval(DayTime)` and `Interval(YearMonth)` is itself unimplemented. So it is left alone rather than widened on speculation. - A `DATE` bound and a `TIMESTAMP` bound still cannot be mixed. PostgreSQL and DuckDB both accept that mix. It is out of scope for a precision fix, and the new message at least names the type now. ## What is the testing strategy for this PR? All coverage is in sqllogictest, in a new section of `datafusion/sqllogictest/test_files/table_functions.slt` beside the existing timestamp-range tests: - all four units, for `generate_series` and for `range` - a sub-second step over second-precision bounds - mixed-precision bounds in both directions - `arrow_typeof` assertions that the output is `Timestamp(Nanosecond, tz)` whatever the input unit - bounds with two different timezones, in both orders (the swapped order returns fewer rows, which shows that the bounds compare as instants) - typed and untyped NULL bounds - the edge of the nanosecond range for `Second`, `Millisecond` and `Microsecond`, in both directions, and one unit past each edge - the error messages for a wrong type and for a non-literal argument ``` cargo test -p datafusion-sqllogictest --test sqllogictests -- table_functions cargo clippy -p datafusion-functions-table --all-targets -- -D warnings ``` ## Are there any user-facing changes? Yes. Both of them widen behaviour rather than break it. - `generate_series` and `range` accept `Timestamp(Second|Millisecond|Microsecond, _)` bounds, which errored before. Queries that worked before keep working, and the result type does not change. - Several plan error messages are reworded to name the rejected data type. There are no public API changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 <[email protected]>
1 parent 56cad07 commit 5a7420e

2 files changed

Lines changed: 268 additions & 27 deletions

File tree

‎datafusion/functions-table/src/generate_series.rs‎

Lines changed: 90 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,54 @@ fn reach_end_int64(val: i64, end: i64, step: i64, include_end: bool) -> bool {
534534
}
535535
}
536536

537+
/// `i64::MIN` nanoseconds since the Unix epoch, rendered as a timestamp.
538+
const NANOS_RANGE_MIN: &str = "1677-09-21T00:12:43.145224192";
539+
/// `i64::MAX` nanoseconds since the Unix epoch, rendered as a timestamp.
540+
const NANOS_RANGE_MAX: &str = "2262-04-11T23:47:16.854775807";
541+
542+
/// Reads a timestamp literal of any [`TimeUnit`] as nanoseconds since the
543+
/// epoch, plus its timezone. A NULL yields `None`. Errors if the value does not
544+
/// fit in an `i64` of nanoseconds.
545+
fn timestamp_arg_to_nanos(
546+
expr: &Expr,
547+
arg_desc: &str,
548+
name: &str,
549+
) -> Result<(Option<i64>, Option<Arc<str>>)> {
550+
let Expr::Literal(scalar, _) = expr else {
551+
return plan_err!(
552+
"{arg_desc} for {name} must be a TIMESTAMP or NULL constant, got {expr}"
553+
);
554+
};
555+
556+
let (value, nanos_per_unit, tz) = match scalar {
557+
ScalarValue::Null => return Ok((None, None)),
558+
ScalarValue::TimestampSecond(v, tz) => (v, 1_000_000_000i64, tz),
559+
ScalarValue::TimestampMillisecond(v, tz) => (v, 1_000_000, tz),
560+
ScalarValue::TimestampMicrosecond(v, tz) => (v, 1_000, tz),
561+
ScalarValue::TimestampNanosecond(v, tz) => (v, 1, tz),
562+
other => {
563+
return plan_err!(
564+
"{arg_desc} for {name} must be a TIMESTAMP or NULL constant, got {:?}",
565+
other.data_type()
566+
);
567+
}
568+
};
569+
570+
let Some(value) = value else {
571+
return Ok((None, tz.clone()));
572+
};
573+
574+
let nanos = value.checked_mul(nanos_per_unit).ok_or_else(|| {
575+
plan_datafusion_err!(
576+
"{arg_desc} for {name} is out of range of nanosecond timestamps: \
577+
{value} ({:?}) is outside {NANOS_RANGE_MIN} to {NANOS_RANGE_MAX}",
578+
scalar.data_type()
579+
)
580+
})?;
581+
582+
Ok((Some(nanos), tz.clone()))
583+
}
584+
537585
fn validate_interval_step(step: IntervalMonthDayNano) -> Result<()> {
538586
if step.months == 0 && step.days == 0 && step.nanoseconds == 0 {
539587
return plan_err!("Step interval cannot be zero");
@@ -673,38 +721,29 @@ impl GenerateSeriesFuncImpl {
673721
);
674722
}
675723

676-
// Parse start timestamp
677-
let (start_ts, tz) = match &exprs[0] {
678-
Expr::Literal(ScalarValue::TimestampNanosecond(ts, tz), _) => {
679-
(*ts, tz.clone())
680-
}
681-
other => {
682-
return plan_err!(
683-
"First argument must be a timestamp or NULL, got {:?}",
684-
other
685-
);
686-
}
687-
};
724+
let (start_ts, tz) =
725+
timestamp_arg_to_nanos(&exprs[0], "First argument", self.name)?;
726+
let (end_ts, _end_tz) =
727+
timestamp_arg_to_nanos(&exprs[1], "Second argument", self.name)?;
688728

689-
// Parse end timestamp
690-
let end_ts = match &exprs[1] {
691-
Expr::Literal(ScalarValue::Null, _) => None,
692-
Expr::Literal(ScalarValue::TimestampNanosecond(ts, _), _) => *ts,
693-
other => {
694-
return plan_err!(
695-
"Second argument must be a timestamp or NULL, got {:?}",
696-
other
697-
);
698-
}
699-
};
729+
// The output timezone (which also drives month/day step arithmetic)
730+
// comes from the start. The end's zone does not change its instant.
700731

701732
// Parse step interval
702733
let step_interval = match &exprs[2] {
703734
Expr::Literal(ScalarValue::Null, _) => None,
704735
Expr::Literal(ScalarValue::IntervalMonthDayNano(interval), _) => *interval,
736+
Expr::Literal(scalar, _) => {
737+
return plan_err!(
738+
"Third argument for {} must be an INTERVAL or NULL constant, got {:?}",
739+
self.name,
740+
scalar.data_type()
741+
);
742+
}
705743
other => {
706744
return plan_err!(
707-
"Third argument must be an interval or NULL, got {:?}",
745+
"Third argument for {} must be an INTERVAL or NULL constant, got {}",
746+
self.name,
708747
other
709748
);
710749
}
@@ -765,9 +804,17 @@ impl GenerateSeriesFuncImpl {
765804
args: GenSeriesArgs::ContainsNull { name: self.name },
766805
}));
767806
}
807+
Expr::Literal(scalar, _) => {
808+
return plan_err!(
809+
"First argument for {} must be a DATE or NULL constant, got {:?}",
810+
self.name,
811+
scalar.data_type()
812+
);
813+
}
768814
other => {
769815
return plan_err!(
770-
"First argument must be a date or NULL, got {:?}",
816+
"First argument for {} must be a DATE or NULL constant, got {}",
817+
self.name,
771818
other
772819
);
773820
}
@@ -783,9 +830,17 @@ impl GenerateSeriesFuncImpl {
783830
args: GenSeriesArgs::ContainsNull { name: self.name },
784831
}));
785832
}
833+
Expr::Literal(scalar, _) => {
834+
return plan_err!(
835+
"Second argument for {} must be a DATE or NULL constant, got {:?}",
836+
self.name,
837+
scalar.data_type()
838+
);
839+
}
786840
other => {
787841
return plan_err!(
788-
"Second argument must be a date or NULL, got {:?}",
842+
"Second argument for {} must be a DATE or NULL constant, got {}",
843+
self.name,
789844
other
790845
);
791846
}
@@ -803,9 +858,17 @@ impl GenerateSeriesFuncImpl {
803858
args: GenSeriesArgs::ContainsNull { name: self.name },
804859
}));
805860
}
861+
Expr::Literal(scalar, _) => {
862+
return plan_err!(
863+
"Third argument for {} must be an INTERVAL or NULL constant, got {:?}",
864+
self.name,
865+
scalar.data_type()
866+
);
867+
}
806868
other => {
807869
return plan_err!(
808-
"Third argument must be an interval or NULL, got {:?}",
870+
"Third argument for {} must be an INTERVAL or NULL constant, got {}",
871+
self.name,
809872
other
810873
);
811874
}

‎datafusion/sqllogictest/test_files/table_functions.slt‎

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,184 @@ SELECT * FROM generate_series(DATE '2262-04-10', DATE '2262-04-11', INTERVAL '2'
259259
----
260260
2262-04-10T00:00:00
261261

262+
#
263+
# Timestamp bounds of every precision
264+
# https://github.com/apache/datafusion/issues/25169
265+
#
266+
267+
query P
268+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Second, None)'), INTERVAL '1' DAY)
269+
----
270+
2024-01-01T00:00:00
271+
2024-01-02T00:00:00
272+
2024-01-03T00:00:00
273+
274+
query P
275+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Millisecond, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Millisecond, None)'), INTERVAL '1' DAY)
276+
----
277+
2024-01-01T00:00:00
278+
2024-01-02T00:00:00
279+
2024-01-03T00:00:00
280+
281+
query P
282+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Microsecond, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Microsecond, None)'), INTERVAL '1' DAY)
283+
----
284+
2024-01-01T00:00:00
285+
2024-01-02T00:00:00
286+
2024-01-03T00:00:00
287+
288+
query P
289+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Nanosecond, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Nanosecond, None)'), INTERVAL '1' DAY)
290+
----
291+
2024-01-01T00:00:00
292+
2024-01-02T00:00:00
293+
2024-01-03T00:00:00
294+
295+
query P
296+
SELECT * FROM range(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Second, None)'), INTERVAL '1' DAY)
297+
----
298+
2024-01-01T00:00:00
299+
2024-01-02T00:00:00
300+
301+
query P
302+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-01T00:00:01', 'Timestamp(Second, None)'), INTERVAL '250' MILLISECOND)
303+
----
304+
2024-01-01T00:00:00
305+
2024-01-01T00:00:00.250
306+
2024-01-01T00:00:00.500
307+
2024-01-01T00:00:00.750
308+
2024-01-01T00:00:01
309+
310+
# Mixed precisions
311+
query P
312+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Microsecond, None)'), INTERVAL '1' DAY)
313+
----
314+
2024-01-01T00:00:00
315+
2024-01-02T00:00:00
316+
2024-01-03T00:00:00
317+
318+
query P
319+
SELECT * FROM range(arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Millisecond, None)'), arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), INTERVAL '-1' DAY)
320+
----
321+
2024-01-03T00:00:00
322+
2024-01-02T00:00:00
323+
324+
# Output is always nanoseconds
325+
query T
326+
SELECT DISTINCT arrow_typeof(value) FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-02T00:00:00', 'Timestamp(Second, None)'), INTERVAL '1' DAY)
327+
----
328+
Timestamp(ns)
329+
330+
query T
331+
SELECT DISTINCT arrow_typeof(value) FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00Z', 'Timestamp(Second, Some("+05:00"))'), arrow_cast(TIMESTAMP '2024-01-02T00:00:00Z', 'Timestamp(Second, Some("+05:00"))'), INTERVAL '1' DAY)
332+
----
333+
Timestamp(ns, "+05:00")
334+
335+
# Mixed timezones: the output uses the start's timezone
336+
query T
337+
SELECT DISTINCT arrow_typeof(value) FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00Z', 'Timestamp(Second, Some("+05:00"))'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00Z', 'Timestamp(Microsecond, Some("America/New_York"))'), INTERVAL '1' DAY)
338+
----
339+
Timestamp(ns, "+05:00")
340+
341+
query P
342+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00Z', 'Timestamp(Second, Some("+05:00"))'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00Z', 'Timestamp(Microsecond, Some("America/New_York"))'), INTERVAL '1' DAY)
343+
----
344+
2024-01-01T00:00:00+05:00
345+
2024-01-02T00:00:00+05:00
346+
2024-01-03T00:00:00+05:00
347+
348+
# Bounds compare as instants: 2024-01-01T05:00Z to 2024-01-02T19:00Z
349+
query P
350+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00Z', 'Timestamp(Microsecond, Some("America/New_York"))'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00Z', 'Timestamp(Second, Some("+05:00"))'), INTERVAL '1' DAY)
351+
----
352+
2024-01-01T00:00:00-05:00
353+
2024-01-02T00:00:00-05:00
354+
355+
# NULL bounds
356+
query P
357+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), arrow_cast(NULL, 'Timestamp(Millisecond, None)'), INTERVAL '1' DAY)
358+
----
359+
360+
query P
361+
SELECT * FROM range(arrow_cast(NULL, 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Microsecond, None)'), INTERVAL '1' DAY)
362+
----
363+
364+
query P
365+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), NULL, INTERVAL '1' DAY)
366+
----
367+
368+
# Bounds outside the nanosecond range
369+
statement error DataFusion error: Error during planning: First argument for generate_series is out of range of nanosecond timestamps: 9223372036854775807 \(Timestamp\(Second, None\)\) is outside 1677\-09\-21T00:12:43\.145224192 to 2262\-04\-11T23:47:16\.854775807
370+
SELECT * FROM generate_series(arrow_cast(9223372036854775807, 'Timestamp(Second, None)'), arrow_cast(0, 'Timestamp(Second, None)'), INTERVAL '-1' DAY)
371+
372+
statement error DataFusion error: Error during planning: Second argument for generate_series is out of range of nanosecond timestamps: \-9223372036854775808 \(Timestamp\(Millisecond, None\)\) is outside 1677\-09\-21T00:12:43\.145224192 to 2262\-04\-11T23:47:16\.854775807
373+
SELECT * FROM generate_series(arrow_cast(0, 'Timestamp(Millisecond, None)'), arrow_cast(-9223372036854775808, 'Timestamp(Millisecond, None)'), INTERVAL '-1' DAY)
374+
375+
statement error DataFusion error: Error during planning: First argument for range is out of range of nanosecond timestamps: 9223372036854775807 \(Timestamp\(Microsecond, None\)\) is outside
376+
SELECT * FROM range(arrow_cast(9223372036854775807, 'Timestamp(Microsecond, None)'), arrow_cast(0, 'Timestamp(Microsecond, None)'), INTERVAL '-1' DAY)
377+
378+
# Edge of the nanosecond range for each unit
379+
query P
380+
SELECT * FROM generate_series(arrow_cast(9223372036, 'Timestamp(Second, None)'), arrow_cast(9223372036, 'Timestamp(Second, None)'), INTERVAL '1' DAY)
381+
----
382+
2262-04-11T23:47:16
383+
384+
query P
385+
SELECT * FROM generate_series(arrow_cast(-9223372036854775, 'Timestamp(Microsecond, None)'), arrow_cast(-9223372036854775, 'Timestamp(Microsecond, None)'), INTERVAL '1' DAY)
386+
----
387+
1677-09-21T00:12:43.145225
388+
389+
query P
390+
SELECT * FROM generate_series(arrow_cast(-9223372036, 'Timestamp(Second, None)'), arrow_cast(-9223372036, 'Timestamp(Second, None)'), INTERVAL '1' DAY)
391+
----
392+
1677-09-21T00:12:44
393+
394+
query P
395+
SELECT * FROM generate_series(arrow_cast(9223372036854, 'Timestamp(Millisecond, None)'), arrow_cast(9223372036854, 'Timestamp(Millisecond, None)'), INTERVAL '1' DAY)
396+
----
397+
2262-04-11T23:47:16.854
398+
399+
query P
400+
SELECT * FROM generate_series(arrow_cast(-9223372036854, 'Timestamp(Millisecond, None)'), arrow_cast(-9223372036854, 'Timestamp(Millisecond, None)'), INTERVAL '1' DAY)
401+
----
402+
1677-09-21T00:12:43.146
403+
404+
query P
405+
SELECT * FROM generate_series(arrow_cast(9223372036854775, 'Timestamp(Microsecond, None)'), arrow_cast(9223372036854775, 'Timestamp(Microsecond, None)'), INTERVAL '1' DAY)
406+
----
407+
2262-04-11T23:47:16.854775
408+
409+
statement error DataFusion error: Error during planning: First argument for generate_series is out of range of nanosecond timestamps
410+
SELECT * FROM generate_series(arrow_cast(9223372037, 'Timestamp(Second, None)'), arrow_cast(9223372037, 'Timestamp(Second, None)'), INTERVAL '1' DAY)
411+
412+
statement error DataFusion error: Error during planning: First argument for generate_series is out of range of nanosecond timestamps
413+
SELECT * FROM generate_series(arrow_cast(-9223372036854776, 'Timestamp(Microsecond, None)'), arrow_cast(-9223372036854776, 'Timestamp(Microsecond, None)'), INTERVAL '1' DAY)
414+
415+
statement error DataFusion error: Error during planning: First argument for generate_series is out of range of nanosecond timestamps
416+
SELECT * FROM generate_series(arrow_cast(-9223372037, 'Timestamp(Second, None)'), arrow_cast(-9223372037, 'Timestamp(Second, None)'), INTERVAL '1' DAY)
417+
418+
statement error DataFusion error: Error during planning: First argument for generate_series is out of range of nanosecond timestamps
419+
SELECT * FROM generate_series(arrow_cast(9223372036855, 'Timestamp(Millisecond, None)'), arrow_cast(9223372036855, 'Timestamp(Millisecond, None)'), INTERVAL '1' DAY)
420+
421+
statement error DataFusion error: Error during planning: First argument for generate_series is out of range of nanosecond timestamps
422+
SELECT * FROM generate_series(arrow_cast(-9223372036855, 'Timestamp(Millisecond, None)'), arrow_cast(-9223372036855, 'Timestamp(Millisecond, None)'), INTERVAL '1' DAY)
423+
424+
statement error DataFusion error: Error during planning: First argument for generate_series is out of range of nanosecond timestamps
425+
SELECT * FROM generate_series(arrow_cast(9223372036854776, 'Timestamp(Microsecond, None)'), arrow_cast(9223372036854776, 'Timestamp(Microsecond, None)'), INTERVAL '1' DAY)
426+
427+
# Invalid argument types
428+
statement error DataFusion error: Error during planning: Second argument for generate_series must be a TIMESTAMP or NULL constant, got Int64
429+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), 5, INTERVAL '1' DAY)
430+
431+
statement error DataFusion error: Error during planning: Third argument for generate_series must be an INTERVAL or NULL constant, got Utf8
432+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), arrow_cast(TIMESTAMP '2024-01-03T00:00:00', 'Timestamp(Second, None)'), 'not an interval')
433+
434+
statement error DataFusion error: Error during planning: Second argument for generate_series must be a DATE or NULL constant, got Int64
435+
SELECT * FROM generate_series(DATE '2024-01-01', 5, INTERVAL '1' DAY)
436+
437+
statement error DataFusion error: Error during planning: Second argument for generate_series must be a TIMESTAMP or NULL constant, got \(<subquery>\)
438+
SELECT * FROM generate_series(arrow_cast(TIMESTAMP '2024-01-01T00:00:00', 'Timestamp(Second, None)'), (SELECT TIMESTAMP '2024-01-03T00:00:00'), INTERVAL '1' DAY)
439+
262440
# UDF and UDTF `generate_series` can be used simultaneously
263441
query ? rowsort
264442
SELECT generate_series(1, t1.end) FROM generate_series(3, 5) as t1(end)

0 commit comments

Comments
 (0)