Skip to content

INTERVAL 1 WEEK in SQL is wrong interval #18665

Open

Description

@JRobTS

The INTERVAL 1 WEEK syntax in SQL is resolving to PT1H.

Affected Version

Found in Apache Druid 33.0.0

Description

Most easily detected by running this SQL query in Unified Console Workbench:

SELECT 
  MILLIS_TO_TIMESTAMP(0) + INTERVAL 1 WEEK,
  MILLIS_TO_TIMESTAMP(0) + INTERVAL 2 WEEK

Expected Results:

EXPR$0,EXPR$1
1970-01-08T00:00:00.000Z,1970-01-15T00:00:00.000Z

Actual Results:

EXPR$0,EXPR$1
1970-01-01T01:00:00.000Z,1970-01-01T02:00:00.000Z

Activity

  1. changed the title [-]INTERVAL 1 WEEK in Druid is wrong interval[/-] [+]INTERVAL 1 WEEK in SQL is wrong interval[/+] on Oct 23, 2025
  2. christian-schlichtherle commented on Feb 10, 2026

    @christian-schlichtherle

    Just ran into the same problem on Druid 34.0.0:

    SELECT
      CURRENT_TIMESTAMP AS now,
      CURRENT_TIMESTAMP - INTERVAL '7' DAYS AS last_week_correct,
      CURRENT_TIMESTAMP - INTERVAL '1' WEEK AS last_week_wrong
    ```
    
  3. barry3406 commented on Apr 11, 2026

    @barry3406

    I can repro on Druid 34.0.0 — INTERVAL '1' WEEK resolves to PT1H instead of P7D. Looks like the WEEK unit is missing from the Calcite-to-Druid interval conversion (most other units land in the day path but WEEK falls through to hours). Going to dig in and send a PR with a SqlIntervalArithmeticTest covering WEEK alongside the existing DAY/MONTH cases.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions