Skip to content

Filter by time measure doesn't work #9435

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

Open
Anger79 opened this issue Apr 7, 2025 · 5 comments
Open

Filter by time measure doesn't work #9435

Anger79 opened this issue Apr 7, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@Anger79
Copy link

Anger79 commented Apr 7, 2025

Problem

I don't understand how to apply filter by time measure (timestampMin or timestampMax) in a cubejs playground and whether it's possible or not. I'm getting "TypeError: Cannot read properties of null (reading 'split')" when I'm trying to add a filter like timestampMin in date range/not in date range/before date/after date. No sql generated, "Run Query" button is inactive.

I do able to filter by requests measure.

Cube.js schema

cube(`Cube`, {
  ...
    measures: {
        requests: {
            sql: `count`,
            type: `sum`
        },
        timestampMin: {
            sql: `min(timestamp)`,
            type: `time`
        },
        timestampMax: {
            sql: `max(timestamp)`,
            type: `time`
        },
    },
    dimensions: {
        ....
        timestamp: {
            sql: `timestamp`,
            type: `time`
        },
        .....
})

Cubejs version: v1.2.30

Data source: Clickhouse

@Anger79 Anger79 added the question The issue is a question. Please use Stack Overflow for questions. label Apr 7, 2025
@igorlukanin
Copy link
Member

Hi @Anger79 👋

You can add a filter by time dimension in the following way. Please check screenshots:

Image Image

That one will translate to the dateRange parameter in the timeDimension part of the query.

inDateRange, notInDateRange, beforeDate, afterDate filter types are currently not supported in Playground. Anyway, you'd probably be better using the dateRange parameter in timeDimension.

@igorlukanin igorlukanin self-assigned this Apr 14, 2025
@Anger79
Copy link
Author

Anger79 commented Apr 14, 2025

Hi @igorlukanin, Thanks for a quick reply!

But I'm interested in filtering exactly by the time measure, not a time dimension.
There is a difference between fitlering by dimension and by measure, right? Because filter by measure gets converted to the HAVING clause and applied after aggregation in sql query, while fitlering by dimension gets converted to a regular WHERE clause.

So I'm trying to understand if there is a way to apply filter by time measure in a cubejs query, and what is the proper way of doing that if that is supported.

Would be great if you provide query example.
Thanks!

@igorlukanin
Copy link
Member

But I'm interested in filtering exactly by the time measure, not a time dimension.

Oh, sorry, I misread it. Now I see that using these filters lead to an error: TypeError: Cannot read properties of null (reading 'split').

Image

This is not actually specific for Playground, happens in the REST API as well.

@igorlukanin igorlukanin added bug Something isn't working and removed question The issue is a question. Please use Stack Overflow for questions. labels Apr 14, 2025
@igorlukanin igorlukanin removed their assignment Apr 14, 2025
@Anger79
Copy link
Author

Anger79 commented Apr 14, 2025

@igorlukanin Right, I wasn't able to make it work through the REST API, I thought that I'm doing something wrong, and tried the same in the Playground, but it didn't work as well.

@willianba
Copy link

+1
i've been having this same issue since last week too 😔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants