Skip to content

generate_series over timestamps accepts only nanosecond precision, with a misleading error #25169

Description

@adriangb

Describe the bug

generate_series / range over timestamps accept only nanosecond precision. Any other TimeUnit fails with an error that says the argument is not a timestamp, while naming a timestamp:

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');

Error during planning: First argument must be a timestamp or NULL,
got Literal(TimestampSecond(1704067200, None), None)

The same query with Timestamp(Nanosecond, …) works.

To Reproduce

The query above, on DataFusion 55.0.0 (da89c7c85b).

Expected behavior

Either accept all four TimeUnits (coercing to nanoseconds internally), or produce an error that says what is actually wrong — something like "expects nanosecond precision, got Timestamp(Second)".

The current message is actively misleading: it says the argument must be a timestamp and then prints a timestamp, which sends you looking in the wrong place. This matters more than it looks, because second and millisecond precision are common in Parquet files, so a generate_series over a column read from storage can fail while the same logic written with literals succeeds.

Found while adding timezone characterization tests in #25164.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions