@@ -159,6 +159,15 @@ describe('SQL Generation', () => {
159
159
granularity: 'quarter'
160
160
}
161
161
},
162
+ revenue_qtd_proxy: {
163
+ type: 'sum',
164
+ sql: \`\${revenue}\`,
165
+ multi_stage: true,
166
+ rollingWindow: {
167
+ type: 'to_date',
168
+ granularity: 'quarter'
169
+ }
170
+ },
162
171
revenue_day_ago: {
163
172
multi_stage: true,
164
173
type: 'sum',
@@ -169,6 +178,15 @@ describe('SQL Generation', () => {
169
178
type: 'prior',
170
179
}]
171
180
},
181
+ revenueRollingDayAgo: {
182
+ type: 'sum',
183
+ sql: \`\${revenue_day_ago}\`,
184
+ multi_stage: true,
185
+ rollingWindow: {
186
+ trailing: '2 day',
187
+ offset: 'start'
188
+ }
189
+ },
172
190
revenue_day_ago_no_td: {
173
191
multi_stage: true,
174
192
type: 'sum',
@@ -1033,6 +1051,38 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
1033
1051
{ visitors__created_at_day : '2017-01-10T00:00:00.000Z' , visitors__revenue_rolling : null }
1034
1052
] ) ) ;
1035
1053
1054
+ if ( getEnv ( 'nativeSqlPlanner' ) ) {
1055
+ it ( 'rolling day ago' , async ( ) => runQueryTest ( {
1056
+ measures : [
1057
+ 'visitors.revenueRollingDayAgo'
1058
+ ] ,
1059
+ timeDimensions : [ {
1060
+ dimension : 'visitors.created_at' ,
1061
+ granularity : 'day' ,
1062
+ dateRange : [ '2017-01-01' , '2017-01-10' ]
1063
+ } ] ,
1064
+ order : [ {
1065
+ id : 'visitors.created_at'
1066
+ } ] ,
1067
+ timezone : 'America/Los_Angeles'
1068
+ } , [
1069
+ { visitors__created_at_day : '2017-01-01T00:00:00.000Z' , visitors__revenue_rolling_day_ago : null } ,
1070
+ { visitors__created_at_day : '2017-01-02T00:00:00.000Z' , visitors__revenue_rolling_day_ago : null } ,
1071
+ { visitors__created_at_day : '2017-01-03T00:00:00.000Z' , visitors__revenue_rolling_day_ago : null } ,
1072
+ { visitors__created_at_day : '2017-01-04T00:00:00.000Z' , visitors__revenue_rolling_day_ago : '100' } ,
1073
+ { visitors__created_at_day : '2017-01-05T00:00:00.000Z' , visitors__revenue_rolling_day_ago : '100' } ,
1074
+ { visitors__created_at_day : '2017-01-06T00:00:00.000Z' , visitors__revenue_rolling_day_ago : '200' } ,
1075
+ { visitors__created_at_day : '2017-01-07T00:00:00.000Z' , visitors__revenue_rolling_day_ago : '500' } ,
1076
+ { visitors__created_at_day : '2017-01-08T00:00:00.000Z' , visitors__revenue_rolling_day_ago : '1200' } ,
1077
+ { visitors__created_at_day : '2017-01-09T00:00:00.000Z' , visitors__revenue_rolling_day_ago : '900' } ,
1078
+ { visitors__created_at_day : '2017-01-10T00:00:00.000Z' , visitors__revenue_rolling_day_ago : null }
1079
+ ] ) ) ;
1080
+ } else {
1081
+ it . skip ( 'rolling count without date range' , ( ) => {
1082
+ // Skipping because it works only in Tesseract
1083
+ } ) ;
1084
+ }
1085
+
1036
1086
it ( 'rolling multiplied' , async ( ) => runQueryTest ( {
1037
1087
measures : [
1038
1088
'visitors.revenueRolling' ,
@@ -1702,6 +1752,34 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
1702
1752
{ visitors__created_at_day : '2017-01-10T00:00:00.000Z' , visitors__revenue_qtd : '1500' }
1703
1753
] ) ) ;
1704
1754
1755
+ if ( getEnv ( 'nativeSqlPlanner' ) ) {
1756
+ it ( 'rolling qtd proxy' , async ( ) => runQueryTest ( {
1757
+ measures : [
1758
+ 'visitors.revenue_qtd_proxy'
1759
+ ] ,
1760
+ timeDimensions : [ {
1761
+ dimension : 'visitors.created_at' ,
1762
+ granularity : 'day' ,
1763
+ dateRange : [ '2017-01-05' , '2017-01-10' ]
1764
+ } ] ,
1765
+ order : [ {
1766
+ id : 'visitors.created_at'
1767
+ } ] ,
1768
+ timezone : 'America/Los_Angeles'
1769
+ } , [
1770
+ { visitors__created_at_day : '2017-01-05T00:00:00.000Z' , visitors__revenue_qtd_proxy : '600' } ,
1771
+ { visitors__created_at_day : '2017-01-06T00:00:00.000Z' , visitors__revenue_qtd_proxy : '1500' } ,
1772
+ { visitors__created_at_day : '2017-01-07T00:00:00.000Z' , visitors__revenue_qtd_proxy : '1500' } ,
1773
+ { visitors__created_at_day : '2017-01-08T00:00:00.000Z' , visitors__revenue_qtd_proxy : '1500' } ,
1774
+ { visitors__created_at_day : '2017-01-09T00:00:00.000Z' , visitors__revenue_qtd_proxy : '1500' } ,
1775
+ { visitors__created_at_day : '2017-01-10T00:00:00.000Z' , visitors__revenue_qtd_proxy : '1500' }
1776
+ ] ) ) ;
1777
+ } else {
1778
+ it . skip ( 'rolling qtd proxy' , ( ) => {
1779
+ // Skipping because it works only in Tesseract
1780
+ } ) ;
1781
+ }
1782
+
1705
1783
it ( 'CAGR' , async ( ) => runQueryTest ( {
1706
1784
measures : [
1707
1785
'visitors.revenue' ,
0 commit comments