@@ -9,6 +9,98 @@ import (
99 "github.com/stretchr/testify/require"
1010)
1111
12+ func TestMetricsViewTimeCaseInsensitive (t * testing.T ) {
13+ rt , id := testruntime .NewInstanceWithOptions (t , testruntime.InstanceOptions {
14+ Files : map [string ]string {
15+ "m1.sql" : `SELECT '2024-01-01T00:00:00Z'::TIMESTAMP AS TiMe, 1 AS num` ,
16+ "mv1.yaml" : `
17+ type: metrics_view
18+ model: m1
19+ timeseries: TiMe
20+ measures:
21+ - name: num
22+ expression: sum(num)
23+ explore:
24+ skip: true
25+ ` ,
26+ "mv2.yaml" : `
27+ type: metrics_view
28+ model: m1
29+ timeseries: TiMe
30+ dimensions:
31+ - column: TiMe
32+ measures:
33+ - name: num
34+ expression: sum(num)
35+ explore:
36+ skip: true
37+ ` ,
38+ "mv3.yaml" : `
39+ type: metrics_view
40+ model: m1
41+ timeseries: time
42+ dimensions:
43+ - name: time
44+ column: TiMe
45+ measures:
46+ - name: num
47+ expression: sum(num)
48+ explore:
49+ skip: true
50+ ` ,
51+ "mv4.yaml" : `
52+ type: metrics_view
53+ model: m1
54+ timeseries: time
55+ dimensions:
56+ - column: TiMe
57+ measures:
58+ - name: num
59+ expression: sum(num)
60+ explore:
61+ skip: true
62+ ` ,
63+ "mv5.yaml" : `
64+ type: metrics_view
65+ model: m1
66+ timeseries: TiMe
67+ dimensions:
68+ - name: time
69+ column: TiMe
70+ measures:
71+ - name: num
72+ expression: sum(num)
73+ explore:
74+ skip: true
75+ ` ,
76+ },
77+ })
78+ testruntime .RequireReconcileState (t , rt , id , 5 , 1 , 2 )
79+
80+ r := testruntime .GetResource (t , rt , id , runtime .ResourceKindMetricsView , "mv1" )
81+ require .Empty (t , r .Meta .ReconcileError )
82+ d := r .GetMetricsView ().State .ValidSpec .Dimensions [0 ]
83+ require .Equal (t , runtimev1 .MetricsViewSpec_DIMENSION_TYPE_TIME , d .Type )
84+ require .Equal (t , runtimev1 .Type_CODE_TIMESTAMP , d .DataType .Code )
85+
86+ r = testruntime .GetResource (t , rt , id , runtime .ResourceKindMetricsView , "mv2" )
87+ require .Empty (t , r .Meta .ReconcileError )
88+ d = r .GetMetricsView ().State .ValidSpec .Dimensions [0 ]
89+ require .Equal (t , runtimev1 .MetricsViewSpec_DIMENSION_TYPE_TIME , d .Type )
90+ require .Equal (t , runtimev1 .Type_CODE_TIMESTAMP , d .DataType .Code )
91+
92+ r = testruntime .GetResource (t , rt , id , runtime .ResourceKindMetricsView , "mv3" )
93+ require .Empty (t , r .Meta .ReconcileError )
94+ d = r .GetMetricsView ().State .ValidSpec .Dimensions [0 ]
95+ require .Equal (t , runtimev1 .MetricsViewSpec_DIMENSION_TYPE_TIME , d .Type )
96+ require .Equal (t , runtimev1 .Type_CODE_TIMESTAMP , d .DataType .Code )
97+
98+ testruntime .RequireParseErrors (t , rt , id , map [string ]string {
99+ "/mv4.yaml" : "does not match the case of time dimension" ,
100+ "/mv5.yaml" : "does not match the case of time dimension" ,
101+ })
102+ }
103+
12104func TestMetricsViewTimeTypes (t * testing.T ) {
13105 rt , id := testruntime .NewInstanceWithOptions (t , testruntime.InstanceOptions {
14106 Files : map [string ]string {
0 commit comments