Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last_value()/first_value() returns incorrect and unstable result #4096

Closed
evenyag opened this issue Jun 3, 2024 · 0 comments · Fixed by #4169
Closed

last_value()/first_value() returns incorrect and unstable result #4096

evenyag opened this issue Jun 3, 2024 · 0 comments · Fixed by #4169
Assignees
Labels
C-bug Category Bugs

Comments

@evenyag
Copy link
Contributor

evenyag commented Jun 3, 2024

What type of bug is this?

Incorrect result

What subsystems are affected?

Standalone mode

Minimal reproduce step

CREATE TABLE monitor (
  host STRING,
  ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP() TIME INDEX,
  cpu FLOAT64 DEFAULT 0,
  memory FLOAT64,
  PRIMARY KEY(host)) ENGINE=mito;

INSERT INTO monitor
VALUES
    ("127.0.0.1", 1, 0.5, 0.9),
    ("127.0.0.2", 2, 0.6, 0.8),
    ("127.0.0.3", 3, 0.7, 0.7),
    ("127.0.0.4", 4, 0.8, 0.6),
    ("127.0.0.4", 5, 0.9, 0.5),
    ("127.0.0.5", 6, 1.0, 0.4);

select last_value(cpu order by ts) from monitor;

select first_value(cpu order by ts) from monitor;

What did you expect to see?

select last_value(cpu order by ts) from monitor;

+--------------------------------------------------------------+
| last_value(monitor.cpu) ORDER BY [monitor.ts ASC NULLS LAST] |
+--------------------------------------------------------------+
|                                                            1 |
+--------------------------------------------------------------+

select first_value(cpu order by ts) from monitor;

+---------------------------------------------------------------+
| first_value(monitor.cpu) ORDER BY [monitor.ts ASC NULLS LAST] |
+---------------------------------------------------------------+
|                                                           0.5 |
+---------------------------------------------------------------+

What did you see instead?

select last_value(cpu order by ts) from monitor;
+--------------------------------------------------------------+
| last_value(monitor.cpu) ORDER BY [monitor.ts ASC NULLS LAST] |
+--------------------------------------------------------------+
|                                                          0.6 |
+--------------------------------------------------------------+

select first_value(cpu order by ts) from monitor;
+---------------------------------------------------------------+
| first_value(monitor.cpu) ORDER BY [monitor.ts ASC NULLS LAST] |
+---------------------------------------------------------------+
|                                                           0.6 |
+---------------------------------------------------------------+

What operating system did you use?

Unrelated

What version of GreptimeDB did you use?

0.8.1

Relevant log output and stack trace

NA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants