Skip to content

TIMESTAMP predicate incorrectly matches rows with higher fractional seconds #8214

@fengys1996

Description

@fengys1996

What type of bug is this?

Incorrect result

What subsystems are affected?

Query Engine

Minimal reproduce step

  1. start greptimedb in standalone mode.

  2. create table

CREATE TABLE ts_precision_bug (
    ts TIMESTAMP(3) TIME INDEX,
    v INT,
    PRIMARY KEY (v)
);
  1. insert data
INSERT INTO ts_precision_bug VALUES
    ('2026-06-02 03:49:59.999', 1),
    ('2026-06-02 03:50:00.000', 2),
    ('2026-06-02 03:50:00.195', 3),
    ('2026-06-02 03:50:01.000', 4);
  1. query data
SELECT ts, v
FROM ts_precision_bug
WHERE ts <= '2026-06-02 03:50:00'
ORDER BY ts DESC
LIMIT 1;

What did you expect to see?

+-------------------------+------+
| ts                      | v    |
+-------------------------+------+
| 2026-06-02 03:50:00.000 | 2    |
+-------------------------+------+

What did you see instead?

+-------------------------+------+
| ts                      | v    |
+-------------------------+------+
| 2026-06-02 03:50:00.195 | 3    |
+-------------------------+------+

What operating system did you use?

arch linux

What version of GreptimeDB did you use?

v1.0.2

Relevant log output and stack trace

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory Bugs

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions