Commit 5a2958c
authored
refactor: Convert legacy filter to be filter_query (#128)
### TL;DR
Refactored legacy `filter` query parameter to be `filter_query` JSON format.
#### Before
- `filter`
- `GET /api/pipeline_runs/?filter=created_by:alice`
- `GET /api/pipeline_runs/?filter=created_by:me`
- `filter_query`
- `GET /api/pipeline_runs/?filter_query={"and":[{"value_equals":{"key":"system/pipeline_run.created_by","value":"alice"}}]}`
#### After
- `filter`
- Converts `created_by:alice` or `created_by:me` to be `{"and":[{"value_equals":{"key":"system/pipeline_run.created_by","value":"alice"}}]}`
- `filter_query` no change.
### What changed?
#### Functional
- None. From a user perspective, `filter` and `filter_query` behaves the same.
#### Other
- Replaced `_build_filter_where_clauses` function with `_convert_legacy_filter_to_filter_query` that converts legacy filter strings to filter_query JSON format
- Modified `build_list_filters` to convert legacy filters to filter_query format and process them through the unified filter_query pipeline
- Updated PageToken to store `filter` as `None` and use `filter_query` for all filtering operations
- Added validation to reject empty `created_by` filter values with a clear error message
- The `"me"` value in `created_by:me` filters is no longer resolved during conversion but handled downstream by `_maybe_resolve_system_values`
### How to test?
```
uv run pytest tests/test_api_server_sql.py tests/test_filter_query_sql.py
```
- Test legacy filter conversion with `created_by:alice` filters
- Verify that `created_by:me` filters are converted but not immediately resolved
- Confirm that empty `created_by:` filters raise `ApiValidationError`
- Test pagination with legacy filters to ensure they're properly converted in page tokens
- Verify that unsupported filter keys still raise `NotImplementedError`
### Why make this change?
This change unifies the filter processing pipeline by converting legacy filters to the modern filter_query format, eliminating duplicate SQL generation logic and ensuring consistent behavior between legacy and modern filter formats.1 parent 38dc5e7 commit 5a2958c
3 files changed
Lines changed: 80 additions & 94 deletions
File tree
- cloud_pipelines_backend
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
167 | 167 | | |
| 168 | + | |
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | | - | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
226 | 225 | | |
227 | | - | |
228 | | - | |
229 | | - | |
| 226 | + | |
| 227 | + | |
230 | 228 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
234 | 232 | | |
235 | 233 | | |
236 | 234 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
245 | 238 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
250 | 242 | | |
251 | 243 | | |
252 | | - | |
| 244 | + | |
253 | 245 | | |
254 | 246 | | |
255 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 158 | + | |
172 | 159 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
179 | 165 | | |
180 | 166 | | |
181 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 217 | + | |
224 | 218 | | |
225 | | - | |
| 219 | + | |
226 | 220 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | 221 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
242 | 236 | | |
243 | | - | |
244 | 237 | | |
245 | | - | |
246 | | - | |
| 238 | + | |
| 239 | + | |
247 | 240 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
255 | 246 | | |
256 | 247 | | |
257 | 248 | | |
258 | | - | |
| 249 | + | |
259 | 250 | | |
260 | | - | |
261 | 251 | | |
262 | 252 | | |
263 | 253 | | |
264 | 254 | | |
265 | | - | |
| 255 | + | |
266 | 256 | | |
267 | | - | |
268 | 257 | | |
269 | 258 | | |
270 | 259 | | |
| |||
294 | 283 | | |
295 | 284 | | |
296 | 285 | | |
297 | | - | |
| 286 | + | |
298 | 287 | | |
299 | 288 | | |
300 | 289 | | |
| |||
303 | 292 | | |
304 | 293 | | |
305 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
306 | 302 | | |
307 | 303 | | |
308 | | - | |
| 304 | + | |
| 305 | + | |
309 | 306 | | |
310 | 307 | | |
311 | 308 | | |
312 | | - | |
| 309 | + | |
313 | 310 | | |
314 | 311 | | |
315 | 312 | | |
| |||
326 | 323 | | |
327 | 324 | | |
328 | 325 | | |
329 | | - | |
| 326 | + | |
330 | 327 | | |
331 | 328 | | |
332 | 329 | | |
| |||
342 | 339 | | |
343 | 340 | | |
344 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
345 | 349 | | |
346 | 350 | | |
347 | | - | |
| 351 | + | |
| 352 | + | |
348 | 353 | | |
349 | 354 | | |
350 | 355 | | |
| |||
379 | 384 | | |
380 | 385 | | |
381 | 386 | | |
382 | | - | |
| 387 | + | |
383 | 388 | | |
384 | 389 | | |
385 | 390 | | |
| |||
388 | 393 | | |
389 | 394 | | |
390 | 395 | | |
391 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
392 | 400 | | |
393 | 401 | | |
394 | 402 | | |
| |||
0 commit comments