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

Implement the aggregate function increase #1475

Closed
ZuoTiJia opened this issue Sep 5, 2023 · 0 comments
Closed

Implement the aggregate function increase #1475

ZuoTiJia opened this issue Sep 5, 2023 · 0 comments
Assignees
Labels
component/function documentation Improvements or additions to documentation
Milestone

Comments

@ZuoTiJia
Copy link
Contributor

ZuoTiJia commented Sep 5, 2023

Is your feature request related to a problem? Please describe.

increase (time, value order by time)

time: Timestamp

value: Numeric

The increase function can count increases.
When an interrupt occurs, restore the increment.

create database if not exists test_increase;

alter database test_increase set ttl '100000d';

CREATE TABLE IF NOT EXISTS test_increase.test_increase(f0 BIGINT, tags(t0));

INSERT INTO test_increase.test_increase(TIME, t0, f0)
VALUES
    ('1999-12-31 00:00:00.000', 'a', 1),
    ('1999-12-31 00:00:00.005', 'a', 2),
    ('1999-12-31 00:00:00.010', 'a', 3),
    ('1999-12-31 00:00:00.015', 'a', 4),
    ('1999-12-31 00:00:00.020', 'a', 5),
    ('1999-12-31 00:00:00.025', 'a', 6),
    ('1999-12-31 00:00:00.030', 'a', 7),
    ('1999-12-31 00:00:00.035', 'a', 8);

INSERT INTO test_increase.test_increase(TIME, t0, f0)
VALUES
    ('1999-12-31 00:00:00.000', 'b', 1),
    ('1999-12-31 00:00:00.005', 'b', 2),
    ('1999-12-31 00:00:00.010', 'b', 3),
    ('1999-12-31 00:00:00.015', 'b', 4),
    ('1999-12-31 00:00:00.020', 'b', 1),
    ('1999-12-31 00:00:00.025', 'b', 2),
    ('1999-12-31 00:00:00.030', 'b', 3),
    ('1999-12-31 00:00:00.035', 'b', 4);

query 
select t0, increase(time, f0 order by time) from test_increase.test_increase group by t0;
----
a 7
b 7

Additional context
Prometheus increase https://prometheus.io/docs/prometheus/latest/querying/functions/#increase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/function documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants