Skip to content

Alignment for sample by week gives unexpected behaviour #5776

@bobreim

Description

@bobreim

To reproduce

Given the following table:

CREATE TABLE points (  
  timestamp TIMESTAMP,  
  value DOUBLE,
  name SYMBOL
)  TIMESTAMP(timestamp)
PARTITION BY DAY
DEDUP UPSERT KEYS(timestamp, name);`

INSERT INTO points  
VALUES
  ('2025-02-01T10:00:00.000Z', 1.0, 'point'),
  ('2025-02-02T10:00:00.000Z', 2.0, 'point'),
  ('2025-02-03T10:00:00.000Z', 3.0, 'point'),
  ('2025-02-04T10:00:00.000Z', 4.0, 'point'),
  ('2025-02-05T10:00:00.000Z', 5.0, 'point'),
  ('2025-02-06T10:00:00.000Z', 6.0, 'point'),
  ('2025-02-07T10:00:00.000Z', 7.0, 'point'),
  ('2025-02-08T10:00:00.000Z', 8.0, 'point'),
  ('2025-02-09T10:00:00.000Z', 9.0, 'point'),
  ('2025-02-10T10:00:00.000Z', 10.0, 'point'),
  ('2025-02-11T10:00:00.000Z', 11.0, 'point');

This query:

SELECT timestamp, first(value)
FROM points
WHERE name = 'point'
SAMPLE BY 1w
ALIGN TO CALENDAR

Gives results as expected starting with a timestamp 2025-01-27T00:00:00.000000Z - Monday start of the week.
However, the following query:

SELECT timestamp, first(value)
FROM points
WHERE name = 'point'
SAMPLE BY 1w
ALIGN TO CALENDAR TIME ZONE 'Europe/Amsterdam'

Gives a result starting with a timestamp 2025-01-29T23:00:00.000000Z - a Wednesday.

I would expect timestamp 2025-01-26T23:00:00.000000Z

QuestDB version:

8.1.4

OS, in case of Docker specify Docker and the Host OS:

Debian GNU/Linux 12 (Docker), macOS 15.3.2 (Host OS)

File System, in case of Docker specify Host File System:

APFS

Full Name:

Bob Reimink

Affiliation:

Chainless

Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?

  • Yes, I have

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions