Skip to content

Commit ef59eb7

Browse files
committed
add tests for pre-aggs
1 parent 67c12ef commit ef59eb7

File tree

3 files changed

+361
-140
lines changed

3 files changed

+361
-140
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
cube('validate_preaggs', {
2+
sql_table: 'public.orders',
3+
4+
dimensions: {
5+
id: {
6+
sql: 'id',
7+
type: 'number',
8+
primary_key: true,
9+
},
10+
11+
status: {
12+
sql: 'status',
13+
type: 'string',
14+
},
15+
16+
created_at: {
17+
sql: 'created_at',
18+
type: 'time',
19+
},
20+
21+
completed_at: {
22+
sql: 'completed_at',
23+
type: 'time',
24+
},
25+
},
26+
27+
measures: {
28+
count: {
29+
type: 'count',
30+
},
31+
},
32+
33+
hierarchies: {
34+
hello: {
35+
title: 'World',
36+
levels: [status],
37+
},
38+
},
39+
40+
preAggregations: {
41+
autoRollupFail: {
42+
type: 'autoRollup',
43+
maxPreAggregations: 'string_instead_of_number',
44+
},
45+
46+
originalSqlFail: {
47+
type: 'originalSql',
48+
partitionGranularity: 'invalid_partition_granularity',
49+
},
50+
51+
originalSqlFail2: {
52+
type: 'originalSql',
53+
partitionGranularity: 'day',
54+
uniqueKeyColumns: 'not_an_array',
55+
},
56+
57+
rollupJoinFail: {
58+
type: 'rollupJoin',
59+
partitionGranularity: 'day',
60+
// no rollups
61+
},
62+
63+
rollupLambdaFail: {
64+
type: 'rollupLambda',
65+
partitionGranularity: 'day',
66+
granularity: 'day',
67+
time_dimension: created_at,
68+
rollups: not_a_func,
69+
},
70+
71+
rollupFail: {
72+
type: 'rollup',
73+
measures: [CUBE.count],
74+
timeDimension: [CUBE.created_at],
75+
granularity: 'day',
76+
partitionGranularity: 'month',
77+
},
78+
79+
rollupFail2: {
80+
type: 'rollup',
81+
granularity: `day`,
82+
partitionGranularity: `month`,
83+
dimensions: [CUBE.created_at],
84+
measures: [CUBE.count],
85+
timeDimensions: 'created_at',
86+
},
87+
88+
// TODO: implement check for strings in dimensions/measures/timeDimension
89+
// rollupFail3: {
90+
// type: 'rollup',
91+
// granularity: `day`,
92+
// partitionGranularity: `month`,
93+
// dimensions: ['created_at'],
94+
// measures: ['count'],
95+
// timeDimension: 'created_at',
96+
// },
97+
},
98+
});
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
cubes:
2+
- name: validate_preaggs
3+
sql: SELECT * FROM order_users;
4+
5+
measures:
6+
- name: count
7+
sql: id
8+
type: count
9+
dimensions:
10+
- name: id
11+
sql: id
12+
type: number
13+
primary_key: true
14+
15+
- name: name
16+
sql: name
17+
type: string
18+
19+
- name: created_at
20+
sql: created_at
21+
type: time
22+
23+
pre_aggregations:
24+
- name: autoRollupFail
25+
type: autoRollup
26+
maxPreAggregations: string_instead_of_number
27+
28+
- name: originalSqlFail
29+
type: originalSql
30+
partition_granularity: invalid_partition_granularity
31+
32+
- name: originalSqlFail2
33+
type: originalSql
34+
partition_granularity: month
35+
uniqueKeyColumns: not_an_array
36+
37+
- name: rollupJoinFail
38+
type: rollupJoin
39+
partition_granularity: month
40+
# no rollups
41+
42+
- name: rollupLambdaFail
43+
type: rollupLambda
44+
partition_granularity: month
45+
granularity: day
46+
time_dimension: created_at
47+
rollups: not_a_func
48+
49+
- name: rollupFail
50+
type: rollup
51+
measures:
52+
- CUBE.count
53+
time_dimension: # as array
54+
- CUBE.created_at
55+
granularity: day
56+
partition_granularity: month
57+
refresh_key:
58+
every: 1 hour
59+
scheduled_refresh: true
60+
61+
- name: rollupFail2
62+
type: rollup
63+
measures:
64+
- CUBE.count
65+
time_dimensions: CUBE.created_at # not an array

0 commit comments

Comments
 (0)