Commit 34806ac
authored
[OPIK-5023] [BE] refactor(filter): introduce ENUM_LEGACY field type for source legacy fallback (#5846)
* [OPIK-5023] [BE] refactor(filter): introduce ENUM_LEGACY field type for source legacy fallback
Centralise the legacy-fallback operator handling inside ANALYTICS_DB_OPERATOR_MAP
by introducing FieldType.ENUM_LEGACY. The EQUAL and NOT_EQUAL templates for the
new type encode the OR/AND fallback SQL directly in the map, removing the need for
the separate LEGACY_FALLBACK_OPERATOR_MAP and buildWithLegacyFallback method.
TraceField.SOURCE and SpanField.SOURCE are re-typed to ENUM_LEGACY so the behaviour
is driven by the field type, consistent with every other operator/type pair.
* fix(test): add ENUM_LEGACY to exhaustive FieldType switches in filter resource tests
* refactor(tests): delegate filter helper methods to shared FilterTestUtils
Replace duplicate getValidValue/getKey/getInvalidValue implementations
in FindTraceThreadsResourceTest and GetTracesByProjectResourceTest with
delegation to the shared FilterTestUtils utility class.
* fix(filter): fix MissingFormatArgumentException and dedup legacyFallbackDbValue
Fix MissingFormatArgumentException in toAnalyticsDbFilter when an
ENUM_LEGACY field has no legacy fallback for a given value (e.g.
source = "ui"): fall back to the plain ENUM template for that operator
instead of calling template.formatted with too few arguments.
Replace identical legacyFallbackDbValue anonymous overrides on
TraceField.SOURCE and SpanField.SOURCE with a constructor-injected
Function, eliminating the duplicate enum constant body.
* test: add FilterTestUtils shared helper for filter test methods
* refactor(filter): use @requiredargsconstructor and inline FilterTestUtils calls
* fix: add missing FilterTestUtils import in FindSpansResourceTest
* [OPIK-5023] [BE] refactor: apply ENUM_LEGACY function-based pattern to TraceThreadField
* [OPIK-5023] [BE] refactor(filter): move legacy fallback logic to FieldType
Per review feedback:
- ENUM_LEGACY.buildFilter overrides the FieldType default, encoding the
OR/AND legacy-clause logic directly on the type. Source::legacyFallbackDbValue
is called once, in one place.
- Field enums (SpanField, TraceField, TraceThreadField) no longer carry a
Function<String,Optional<String>> lambda; SOURCE just uses ENUM_LEGACY.
- FilterQueryBuilder.toAnalyticsDbFilter delegates to the type's buildFilter,
removing the if(ENUM_LEGACY) discriminator. Adding a new type with similar
behaviour only requires overriding buildFilter in FieldType.
- legacyFallbackDbValue removed from Field interface; it lives on FieldType.
- FilterTestUtils uses @UtilityClass instead of manual private constructor.1 parent 1e5ac78 commit 34806ac
File tree
11 files changed
+113
-140
lines changed- apps/opik-backend/src
- main/java/com/comet/opik
- api/filter
- domain/filter
- test/java/com/comet/opik/api/resources
- utils
- v1/priv
11 files changed
+113
-140
lines changedLines changed: 0 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
| |||
77 | 75 | | |
78 | 76 | | |
79 | 77 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | 78 | | |
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
29 | 67 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
Lines changed: 2 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | 6 | | |
| 7 | + | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 32 | + | |
41 | 33 | | |
42 | 34 | | |
43 | 35 | | |
| |||
Lines changed: 2 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | 6 | | |
| 7 | + | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 38 | + | |
47 | 39 | | |
48 | 40 | | |
49 | 41 | | |
| |||
Lines changed: 2 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | 6 | | |
| 7 | + | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
22 | 19 | | |
23 | 20 | | |
24 | 21 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 22 | + | |
31 | 23 | | |
32 | 24 | | |
33 | 25 | | |
| |||
Lines changed: 6 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
230 | | - | |
| 231 | + | |
| 232 | + | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| |||
925 | 927 | | |
926 | 928 | | |
927 | 929 | | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
| 930 | + | |
| 931 | + | |
942 | 932 | | |
943 | 933 | | |
944 | 934 | | |
| |||
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Lines changed: 12 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | 469 | | |
499 | 470 | | |
500 | 471 | | |
| |||
505 | 476 | | |
506 | 477 | | |
507 | 478 | | |
508 | | - | |
509 | | - | |
| 479 | + | |
| 480 | + | |
510 | 481 | | |
511 | 482 | | |
512 | 483 | | |
513 | 484 | | |
514 | | - | |
515 | | - | |
| 485 | + | |
| 486 | + | |
516 | 487 | | |
517 | 488 | | |
518 | 489 | | |
519 | 490 | | |
520 | | - | |
521 | | - | |
| 491 | + | |
| 492 | + | |
522 | 493 | | |
523 | 494 | | |
524 | 495 | | |
| |||
536 | 507 | | |
537 | 508 | | |
538 | 509 | | |
539 | | - | |
| 510 | + | |
540 | 511 | | |
541 | 512 | | |
542 | 513 | | |
543 | 514 | | |
544 | 515 | | |
545 | 516 | | |
546 | 517 | | |
547 | | - | |
548 | | - | |
| 518 | + | |
| 519 | + | |
549 | 520 | | |
550 | 521 | | |
551 | 522 | | |
| |||
557 | 528 | | |
558 | 529 | | |
559 | 530 | | |
560 | | - | |
| 531 | + | |
561 | 532 | | |
562 | 533 | | |
563 | 534 | | |
564 | 535 | | |
565 | 536 | | |
566 | | - | |
| 537 | + | |
567 | 538 | | |
568 | 539 | | |
569 | 540 | | |
| |||
0 commit comments