@@ -142,45 +142,45 @@ func TestClickhouseAdapter_InterpretDataQualityCheck(t *testing.T) {
142142 name : "raw_query check" ,
143143 check : & dbqcore.DataQualityCheck {
144144 Expression : "raw_query" ,
145- Query : "SELECT count(*) FROM {{dataset}} WHERE status = 'active'" ,
145+ Query : "select count(*) from {{dataset}} where status = 'active'" ,
146146 ParsedCheck : createMockParsedCheck ("raw_query" , []string {}, "" , nil ),
147147 },
148148 dataset : "users" ,
149149 whereClause : "" ,
150- expectedSQL : "SELECT count(*) FROM users WHERE status = 'active'" ,
150+ expectedSQL : "select count(*) from users where status = 'active'" ,
151151 },
152152 {
153153 name : "raw_query check with where clause" ,
154154 check : & dbqcore.DataQualityCheck {
155155 Expression : "raw_query" ,
156- Query : "SELECT count(*) FROM {{dataset}}" ,
156+ Query : "select count(*) from {{dataset}}" ,
157157 ParsedCheck : createMockParsedCheck ("raw_query" , []string {}, "" , nil ),
158158 },
159159 dataset : "products" ,
160160 whereClause : "category = 'electronics'" ,
161- expectedSQL : "SELECT count(*) FROM products where category = 'electronics'" ,
161+ expectedSQL : "select count(*) from products where category = 'electronics'" ,
162162 },
163163 {
164164 name : "raw_query check with existing where clause" ,
165165 check : & dbqcore.DataQualityCheck {
166166 Expression : "raw_query" ,
167- Query : "SELECT AVG (price) FROM {{dataset}} WHERE category = 'books'" ,
167+ Query : "select avg (price) from {{dataset}} where category = 'books'" ,
168168 ParsedCheck : createMockParsedCheck ("raw_query" , []string {}, "" , nil ),
169169 },
170170 dataset : "products" ,
171171 whereClause : "active = 1" ,
172- expectedSQL : "SELECT AVG (price) FROM products WHERE category = 'books' and (active = 1)" ,
172+ expectedSQL : "select avg (price) from products where category = 'books' and (active = 1)" ,
173173 },
174174 {
175175 name : "raw_query check with multiline query" ,
176176 check : & dbqcore.DataQualityCheck {
177177 Expression : "raw_query" ,
178- Query : "SELECT count(*)\n FROM {{dataset}}\n WHERE active = 1" ,
178+ Query : "select count(*)\n from {{dataset}}\n where active = 1" ,
179179 ParsedCheck : createMockParsedCheck ("raw_query" , []string {}, "" , nil ),
180180 },
181181 dataset : "orders" ,
182182 whereClause : "" ,
183- expectedSQL : "SELECT count(*) FROM orders WHERE active = 1" ,
183+ expectedSQL : "select count(*) from orders where active = 1" ,
184184 },
185185 {
186186 name : "raw_query check missing query field" ,
@@ -194,6 +194,57 @@ func TestClickhouseAdapter_InterpretDataQualityCheck(t *testing.T) {
194194 expectError : true ,
195195 errorMessage : "raw_query check requires a 'query' field" ,
196196 },
197+ {
198+ name : "expect_columns_ordered check" ,
199+ check : & dbqcore.DataQualityCheck {
200+ Expression : "expect_columns_ordered" ,
201+ SchemaCheck : & dbqcore.SchemaCheckConfig {
202+ ExpectColumnsOrdered : & dbqcore.ExpectColumnsOrderedConfig {
203+ ColumnsOrder : []string {"id" , "name" , "email" },
204+ },
205+ },
206+ },
207+ dataset : "default.users" ,
208+ whereClause : "" ,
209+ expectedSQL : `select count()
210+ from system.columns
211+ where database = 'default'
212+ and table = 'users'
213+ and ((name = 'id' and position = 1) or (name = 'name' and position = 2) or (name = 'email' and position = 3))` ,
214+ },
215+ {
216+ name : "expect_columns_ordered check with single column" ,
217+ check : & dbqcore.DataQualityCheck {
218+ Expression : "expect_columns_ordered" ,
219+ SchemaCheck : & dbqcore.SchemaCheckConfig {
220+ ExpectColumnsOrdered : & dbqcore.ExpectColumnsOrderedConfig {
221+ ColumnsOrder : []string {"id" },
222+ },
223+ },
224+ },
225+ dataset : "analytics.events" ,
226+ whereClause : "" ,
227+ expectedSQL : `select count()
228+ from system.columns
229+ where database = 'analytics'
230+ and table = 'events'
231+ and ((name = 'id' and position = 1))` ,
232+ },
233+ {
234+ name : "expect_columns_ordered check invalid dataset format" ,
235+ check : & dbqcore.DataQualityCheck {
236+ Expression : "expect_columns_ordered" ,
237+ SchemaCheck : & dbqcore.SchemaCheckConfig {
238+ ExpectColumnsOrdered : & dbqcore.ExpectColumnsOrderedConfig {
239+ ColumnsOrder : []string {"id" , "name" },
240+ },
241+ },
242+ },
243+ dataset : "invalid_dataset" ,
244+ whereClause : "" ,
245+ expectError : true ,
246+ errorMessage : "dataset must be in format database.table" ,
247+ },
197248 {
198249 name : "unknown function fallback" ,
199250 check : & dbqcore.DataQualityCheck {
0 commit comments