Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ describe('SQL Generation', () => {
granularity: 'quarter'
}
},
revenue_qtd_proxy: {
type: 'sum',
sql: \`\${revenue}\`,
multi_stage: true,
rollingWindow: {
type: 'to_date',
granularity: 'quarter'
}
},
revenue_day_ago: {
multi_stage: true,
type: 'sum',
Expand All @@ -162,6 +171,15 @@ describe('SQL Generation', () => {
type: 'prior',
}]
},
revenueRollingDayAgo: {
type: 'sum',
sql: \`\${revenue_day_ago}\`,
multi_stage: true,
rollingWindow: {
trailing: '2 day',
offset: 'start'
}
},
revenue_day_ago_no_td: {
multi_stage: true,
type: 'sum',
Expand Down Expand Up @@ -1026,6 +1044,38 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
{ visitors__created_at_day: '2017-01-10T00:00:00.000Z', visitors__revenue_rolling: null }
]));

if (getEnv('nativeSqlPlanner')) {
it('rolling day ago', async () => runQueryTest({
measures: [
'visitors.revenueRollingDayAgo'
],
timeDimensions: [{
dimension: 'visitors.created_at',
granularity: 'day',
dateRange: ['2017-01-01', '2017-01-10']
}],
order: [{
id: 'visitors.created_at'
}],
timezone: 'America/Los_Angeles'
}, [
{ visitors__created_at_day: '2017-01-01T00:00:00.000Z', visitors__revenue_rolling_day_ago: null },
{ visitors__created_at_day: '2017-01-02T00:00:00.000Z', visitors__revenue_rolling_day_ago: null },
{ visitors__created_at_day: '2017-01-03T00:00:00.000Z', visitors__revenue_rolling_day_ago: null },
{ visitors__created_at_day: '2017-01-04T00:00:00.000Z', visitors__revenue_rolling_day_ago: '100' },
{ visitors__created_at_day: '2017-01-05T00:00:00.000Z', visitors__revenue_rolling_day_ago: '100' },
{ visitors__created_at_day: '2017-01-06T00:00:00.000Z', visitors__revenue_rolling_day_ago: '200' },
{ visitors__created_at_day: '2017-01-07T00:00:00.000Z', visitors__revenue_rolling_day_ago: '500' },
{ visitors__created_at_day: '2017-01-08T00:00:00.000Z', visitors__revenue_rolling_day_ago: '1200' },
{ visitors__created_at_day: '2017-01-09T00:00:00.000Z', visitors__revenue_rolling_day_ago: '900' },
{ visitors__created_at_day: '2017-01-10T00:00:00.000Z', visitors__revenue_rolling_day_ago: null }
]));
} else {
it.skip('rolling count without date range', () => {
// Skipping because it works only in Tesseract
});
}

it('rolling multiplied', async () => runQueryTest({
measures: [
'visitors.revenueRolling',
Expand Down Expand Up @@ -1474,6 +1524,34 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
{ visitors__created_at_day: '2017-01-10T00:00:00.000Z', visitors__revenue_qtd: '1500' }
]));

if (getEnv('nativeSqlPlanner')) {
it('rolling qtd proxy', async () => runQueryTest({
measures: [
'visitors.revenue_qtd_proxy'
],
timeDimensions: [{
dimension: 'visitors.created_at',
granularity: 'day',
dateRange: ['2017-01-05', '2017-01-10']
}],
order: [{
id: 'visitors.created_at'
}],
timezone: 'America/Los_Angeles'
}, [
{ visitors__created_at_day: '2017-01-05T00:00:00.000Z', visitors__revenue_qtd_proxy: '600' },
{ visitors__created_at_day: '2017-01-06T00:00:00.000Z', visitors__revenue_qtd_proxy: '1500' },
{ visitors__created_at_day: '2017-01-07T00:00:00.000Z', visitors__revenue_qtd_proxy: '1500' },
{ visitors__created_at_day: '2017-01-08T00:00:00.000Z', visitors__revenue_qtd_proxy: '1500' },
{ visitors__created_at_day: '2017-01-09T00:00:00.000Z', visitors__revenue_qtd_proxy: '1500' },
{ visitors__created_at_day: '2017-01-10T00:00:00.000Z', visitors__revenue_qtd_proxy: '1500' }
]));
} else {
it.skip('rolling qtd proxy', () => {
// Skipping because it works only in Tesseract
});
}

it('CAGR', async () => runQueryTest({
measures: [
'visitors.revenue',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ mod member;
mod member_query_planner;
mod multi_stage_query_planner;
mod query_description;
mod rolling_window_planner;

pub use applied_state::*;
pub use member::*;
pub use member_query_planner::MultiStageMemberQueryPlanner;
pub use multi_stage_query_planner::MultiStageQueryPlanner;
pub use query_description::MultiStageQueryDescription;
pub use rolling_window_planner::RollingWindowPlanner;
Loading
Loading