Skip to content

Cumulative count over time in Clickhouse #6333

@Grisgruis

Description

@Grisgruis

Describe the bug
I want to show a cumulative count over time in with Clickhouse

To Reproduce
Steps to reproduce the behavior:

  1. Create Clickhouse data
create database cube;
CREATE TABLE IF NOT EXISTS `cube`.`test` (
  `created_at` Date,
  `count` Int32
)
ENGINE = MergeTree() ORDER BY (created_at) PRIMARY KEY (created_at);
insert into cube.test (*) VALUES (NOW(), 1), (DATESUB(DAY, 1, NOW()), 1)
  1. Create Cube
cube(`Test`, {
    sql: `SELECT * FROM cube.test`,

    measures: {
        count: {
            sql: `count`,
            type: `count`,
        },
        cumulative_count: {
            type: `count`,
            rollingWindow: {
                trailing: `unbounded`,
            },
        },
    },

    dimensions: {
        ts: {
            sql: `${CUBE}."created_at"`,
            type: `time`,
            title: `Timestamp`
        },
    }
});
  1. Go to dashboard, verify that cumulative count works. (without grouping)
    image
  2. Select group by day:
    image
  3. Clickhouse errors with the JOIN ON condition
    Code: 403. DB::Exception: Unsupported JOIN ON conditions. Unexpected 'test__ts_day <= date_to': While processing test__ts_day <= date_to. (INVALID_JOIN_ON_EXPRESSION) (version 23.2.3.17 (official build))

Expected behavior
Be able to show cumulative count over time

Version:
0.32.11

Additional context
Iam aware that the issue lies with Clickhouse. What I am not sure of is;

  • This is not mentioned anywere in the docs as limitations.
  • Is there a possibility to 'overwrite' the join clauses?
  • Any other workarounds/things I should be aware of? Is there any code I could check to fork/alter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugLEGACY. Use the Bug issue type insteadhelp wantedCommunity contributions are welcome.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions