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

fix: adjust fill behavior of range query #3489

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

Taylor-lagrange
Copy link
Contributor

@Taylor-lagrange Taylor-lagrange commented Mar 12, 2024

I hereby agree to the terms of the GreptimeDB CLA.

What's changed and what's your intention?

Adjust fill behavior on range query

  • When user not use fill, the null result calculate by range expr, or the missing datapoint will not be fill.
  • If user use fill NULL, the missing datapoint will be fill.
  • If user use fill LINEAR/PREV/Const, all null value and missing datapoint will be fill.

Case like

CREATE TABLE host (
  ts timestamp(3) time index,
  host STRING PRIMARY KEY,
  val BIGINT,
);

INSERT INTO TABLE host VALUES
    (0,     'host1', 0),
    -- missing data for 5000, 10000
    (15000, 'host1', 6),
    (0,     'host2', 6),
    -- missing data for 5000, 10000
    (15000, 'host2', 12);

SELECT ts, host, min(val) RANGE '5s' FROM host ALIGN '5s' ORDER BY host, ts;

+---------------------+-------+------------------------+
| ts                  | host  | MIN(host.val) RANGE 5s |
+---------------------+-------+------------------------+
| 1970-01-01T00:00:00 | host1 | 0                      |
| 1970-01-01T00:00:15 | host1 | 6                      |
| 1970-01-01T00:00:00 | host2 | 6                      |
| 1970-01-01T00:00:15 | host2 | 12                     |
+---------------------+-------+------------------------+

SELECT ts, host, min(val) RANGE '5s' FILL NULL FROM host ALIGN '5s' ORDER BY host, ts;

+---------------------+-------+----------------------------------+
| ts                  | host  | MIN(host.val) RANGE 5s FILL NULL |
+---------------------+-------+----------------------------------+
| 1970-01-01T00:00:00 | host1 | 0                                |
| 1970-01-01T00:00:05 | host1 |                                  |
| 1970-01-01T00:00:10 | host1 |                                  |
| 1970-01-01T00:00:15 | host1 | 6                                |
| 1970-01-01T00:00:00 | host2 | 6                                |
| 1970-01-01T00:00:05 | host2 |                                  |
| 1970-01-01T00:00:10 | host2 |                                  |
| 1970-01-01T00:00:15 | host2 | 12                               |
+---------------------+-------+----------------------------------+

SELECT ts, host, min(val) RANGE '5s' FILL PREV FROM host ALIGN '5s' ORDER BY host, ts;

+---------------------+-------+----------------------------------+
| ts                  | host  | MIN(host.val) RANGE 5s FILL PREV |
+---------------------+-------+----------------------------------+
| 1970-01-01T00:00:00 | host1 | 0                                |
| 1970-01-01T00:00:05 | host1 | 0                                |
| 1970-01-01T00:00:10 | host1 | 0                                |
| 1970-01-01T00:00:15 | host1 | 6                                |
| 1970-01-01T00:00:00 | host2 | 6                                |
| 1970-01-01T00:00:05 | host2 | 6                                |
| 1970-01-01T00:00:10 | host2 | 6                                |
| 1970-01-01T00:00:15 | host2 | 12                               |
+---------------------+-------+----------------------------------+

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Mar 12, 2024
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 93.85246% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 85.03%. Comparing base (aa125a5) to head (3eecb3e).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3489      +/-   ##
==========================================
- Coverage   85.40%   85.03%   -0.37%     
==========================================
  Files         897      898       +1     
  Lines      148106   148658     +552     
==========================================
- Hits       126495   126417      -78     
- Misses      21611    22241     +630     

@killme2008
Copy link
Contributor

@tisonkun Is this behavior you expected?

Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/query/src/range_select/plan.rs Show resolved Hide resolved
@tisonkun tisonkun self-requested a review March 13, 2024 03:06
@github-actions github-actions bot added docs-required This change requires docs update. and removed docs-not-required This change does not impact docs. labels Mar 13, 2024
Copy link
Collaborator

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Update PR description we need docs update for this.

cc @nicecui

@killme2008 killme2008 added this pull request to the merge queue Mar 13, 2024
Merged via the queue into GreptimeTeam:main with commit fb4da05 Mar 13, 2024
20 checks passed
@Taylor-lagrange Taylor-lagrange deleted the fix-range-fill branch March 21, 2024 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-required This change requires docs update.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants