Description
Describe the bug
This is going to be identical to #9661 but for other operator.
When filtering a timestamp dimension with the "equals" operator, it doesn't bring the correct values due to a wrong logic in the generated SQL.
This is running on postgres.
To Reproduce
Steps to reproduce the behavior (at least the way I ran it):
- Go to Playground
- Filter by any timestamp dimension or metric (like a created_at)
- Select the "equals" operator
- Set the current day value (considering you have data on this day). E.g. 2025-06-05.
Expected behavior
Data on this exact day should be returned.
Screenshots
First, proof that there is data on the requested date.
Now, using equals. All the values on the request date are not present in the response.
Minimally reproducible Cube Schema
cube(`events`, {
sql_table: `public.event`,
data_source: `default`,
dimensions: {
created_at: {
sql: `created_at`,
type: `time`,
},
});
Version:
v1.3.19
Additional context
The example I gave uses a dimension but this bug also happens for measures.
I quickly inspected the generated query and it has the wrong logic.
This is what is being generated:
select
"audience_filter".contact_id "audience_filter__contact_id",
("audience_filter".created_at::timestamptz at TIME zone 'UTC') "audience_filter__created_at"
from
public.event as "audience_filter"
where
("audience_filter".created_at = '2025-06-05') -- this can't be a single string comparison
group by
1,
2
order by
2 desc
limit 10000
From my tests, this "equals" operator should behave as the "in date range" with the same date in both values. This works fine:
select
"audience_filter".contact_id "audience_filter__contact_id",
("audience_filter".created_at::timestamptz at TIME zone 'UTC') "audience_filter__created_at"
from
public.event as "audience_filter"
where
("audience_filter".created_at >= '2025-06-05T00:00:00.000Z'::timestamptz
and "audience_filter".created_at <= '2025-06-05T23:59:59.999Z'::timestamptz)
group by
1,
2
order by
2 desc
limit 10000