You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using rolling windows with filters and joins in Tesseract, invalid SQL is generated that either produces nested aggregations (without multi_stage: true) or incorrect column references (with multi_stage: true).
To Reproduce
Create a schema with two cubes (dates and test) joined together
Add a filtered measure (revenue)
Create a rolling window measure (revenue_ytd) based on the filtered measure
Query the revenue_ytd measure
Error occurs: either "Cannot nest aggregations inside aggregation 'sum'" or "Column 'test.revenue' cannot be resolved"
Expected behavior
The query should generate valid SQL that correctly calculates the year-to-date revenue while respecting both the filter and join conditions.
Minimally reproducible Cube Schema
cubes:
- name: datessql: > SELECT cast('2024-01-13' AS timestamp) as time UNION ALL SELECT cast('2024-02-13' AS timestamp) as time UNION ALL SELECT cast('2024-03-13' AS timestamp) as time UNION ALL SELECT cast('2024-04-13' AS timestamp) as time UNION ALL SELECT cast('2024-05-13' AS timestamp) as time UNION ALL SELECT cast('2024-06-13' AS timestamp) as time UNION ALL SELECT cast('2024-07-13' AS timestamp) as time UNION ALL SELECT cast('2024-08-13' AS timestamp) as time UNION ALL SELECT cast('2024-09-13' AS timestamp) as time UNION ALL SELECT cast('2024-10-13' AS timestamp) as time UNION ALL SELECT cast('2024-11-13' AS timestamp) as time UNION ALL SELECT cast('2024-12-13' AS timestamp) as timedimensions:
- name: timesql: timetype: timeprimary_key: true
- name: testsql: > SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-02-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-03-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-04-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-05-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-06-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-07-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-08-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-09-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-10-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-11-01' AS timestamp) as time UNION ALL SELECT 1 AS revenue, cast('2024-12-01' AS timestamp) as timedimensions:
- name: timesql: timetype: timeprimary_key: truemeasures:
- name: revenuesql: revenuetype: sumfilters:
- sql: "{dates.time} <= current_date"
- name: revenue_ytdsql: "{CUBE.revenue}"type: sumrolling_window:
type: to_dategranularity: yearjoins:
- name: datesrelationship: many_to_onesql: "{CUBE}.time = date_trunc('month',{dates.time})"
Version:
v.1.2.3
Additional Context
The workaround for the sum(sum(revenue)) issue is to change the type of revenue to number (and then create a separate measure if we want a sum). However I have not found a workaround for the Column 'test.revenue' cannot be resolved issue for any multi_stage = true measure
The text was updated successfully, but these errors were encountered:
Describe the bug
When using rolling windows with filters and joins in Tesseract, invalid SQL is generated that either produces nested aggregations (without
multi_stage: true
) or incorrect column references (withmulti_stage: true
).To Reproduce
dates
andtest
) joined togetherrevenue
)revenue_ytd
) based on the filtered measurerevenue_ytd
measureExpected behavior
The query should generate valid SQL that correctly calculates the year-to-date revenue while respecting both the filter and join conditions.
Minimally reproducible Cube Schema
Version:
v.1.2.3
Additional Context
The workaround for the
sum(sum(revenue))
issue is to change thetype
ofrevenue
tonumber
(and then create a separate measure if we want a sum). However I have not found a workaround for theColumn 'test.revenue' cannot be resolved
issue for anymulti_stage = true
measureThe text was updated successfully, but these errors were encountered: