Commit 0b5fd4f
committed
fix(translator): Hash identity-key percentage splits without a context identity
A PERCENTAGE_SPLIT keyed on the identity (implicit `$.identity.key`,
`$.identity.key`, or `$.identity.identifier`) compiled to FALSE when the
evaluation context carried no identity. The translated predicate runs
per-row over IDENTITIES, where the identity-key and identifier columns are
always present, so it should hash the row column regardless of whether the
row-oriented context supplies an identity. The guard made row-oriented
callers (segment-membership counts/members) see every percentage-split
segment as empty.
Drop the eval-context identity guard for those three cases and emit the
per-row hash. Trait-keyed splits are unchanged.
This intentionally diverges from flag_engine's single-eval "no identity ->
False" for the identity-less context, which is correct for the row-oriented
SQL engine where every row is an identity; the one engine-test-data case
that exercises it (test_percentage_split__no_identity_key__should_match) is
added to the ClickHouse harness's _XFAIL_CASE_NAMES. The translator unit
tests assert the full emitted SQL.
beep boop
Claude-Session: https://claude.ai/code/session_01EgZ5iHpDASZzCapiHRxHLB1 parent cfc3d4e commit 0b5fd4f
3 files changed
Lines changed: 45 additions & 24 deletions
File tree
- src/flagsmith_sql_flag_engine
- tests
- harnesses
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
443 | 442 | | |
444 | 443 | | |
445 | | - | |
446 | | - | |
447 | 444 | | |
448 | 445 | | |
449 | | - | |
450 | | - | |
451 | 446 | | |
452 | 447 | | |
453 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
546 | | - | |
547 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
548 | 563 | | |
549 | 564 | | |
550 | 565 | | |
| |||
556 | 571 | | |
557 | 572 | | |
558 | 573 | | |
559 | | - | |
560 | | - | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
561 | 580 | | |
562 | 581 | | |
563 | | - | |
564 | | - | |
| 582 | + | |
| 583 | + | |
565 | 584 | | |
566 | 585 | | |
567 | 586 | | |
| |||
575 | 594 | | |
576 | 595 | | |
577 | 596 | | |
578 | | - | |
579 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
580 | 600 | | |
581 | 601 | | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
586 | 605 | | |
587 | 606 | | |
588 | 607 | | |
| |||
600 | 619 | | |
601 | 620 | | |
602 | 621 | | |
603 | | - | |
604 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
605 | 625 | | |
606 | 626 | | |
607 | 627 | | |
| |||
0 commit comments