Repository navigation
Commit 94dddaa
fix(gooddata-eval): make MAQL comparison case-insensitive for keywords
_normalize_maql/_best_maql_match compare an agent's generated MAQL against
expected_output.maql via exact string equality after whitespace/wrapper
normalization -- but MAQL keywords (SELECT, FOR PREVIOUS, WHERE, BY, ...) are
case-insensitive at the query-engine level (confirmed against the MAQL
reference), while the comparison itself was fully case-sensitive.
Reproduced live in gdc-mic-ai-evaluation, post the #1718 fix: fixture
"Create a metric for the prior-year value of Active cards" expects
SELECT {metric/active_card_count_-_txn_-_cutcgco}
FOR Previous({label/process_date.year})
Agent produced, verbatim:
SELECT {metric/active_card_count_-_txn_-_cutcgco} FOR PREVIOUS({label/process_date.year})
Byte-identical except FOR PREVIOUS vs FOR Previous -- scored as a fail.
First fix attempt considered and rejected: lowercase everything outside
{type/id} braces. That's wrong -- WHERE-clause literal values are ALSO
outside braces (e.g. WHERE {label/status} = "Active") and are real,
case-sensitive data, not keywords; blindly folding them would create a new
false-positive risk (two genuinely different filter values scored as equal).
Actual fix: per the MAQL reference, every literal value is quoted and every
identifier lives inside {..} -- both are exhaustively structural markers, so
protecting text inside either while casefolding everything else needs no
keyword list at all (which would risk being incomplete against MAQL's large
vocabulary: SELECT, BY, WHERE, HAVING, FOR PREVIOUS/NEXT/EACH, WITHOUT PF,
TOP/BOTTOM, WITHIN, RANK family, RUNSUM family, IFNULL, CASE/WHEN, 15+ math
functions, ...). Added _casefold_outside_protected(), applied as the final
step in _normalize_maql.
Tests added:
- keyword case-insensitivity on the exact reproduced case (FOR PREVIOUS vs
FOR Previous)
- identifier case preserved ({metric/Mixed_Case_Id} untouched)
- quoted literal case preserved AND still distinguishes real differences
(WHERE x = "Active" vs WHERE x = "active" must stay a genuine mismatch --
this is the test that would have caught the rejected first draft)
Updated the one existing test whose expected value assumed no case
normalization ever happens (SELECT -> select).
Full gooddata-eval suite: 274 passed, 9 pre-existing unrelated failures
(missing openai extra in this test env; two unrelated test files) --
identical count to before this change.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 47b3216 commit 94dddaa
2 files changed
Lines changed: 45 additions & 3 deletions
File tree
- packages/gooddata-eval
- src/gooddata_eval/core/agentic
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
45 | 64 | | |
46 | | - | |
| 65 | + | |
47 | 66 | | |
48 | 67 | | |
49 | 68 | | |
| |||
56 | 75 | | |
57 | 76 | | |
58 | 77 | | |
59 | | - | |
| 78 | + | |
60 | 79 | | |
61 | 80 | | |
62 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
62 | 85 | | |
63 | 86 | | |
64 | 87 | | |
| |||
0 commit comments