PERCENTAGE_SPLIT: implement engine's 1-in-9999 recursion edge case in SQL
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Locate the inline SQL implementation of PERCENTAGE_SPLIT and compare its bare-hash handling with the engine semantics described in the issue. Implement and verify the doubled-input recursion for bare_hash_mod = 9998, capped at 2-3 iterations, and confirm that ordinary inputs retain their existing results.
Written by the indexing model from the issue text.
Description
The pure-SQL PERCENTAGE_SPLIT hash diverges from the engine on the ~1/9999 inputs where the bare hash mod 9999 == 9998 (the engine recurses with doubled input; this implementation skips).
Real-world impact at typical thresholds: ~0.005% false-negative rate on the count of identities matching a percentage-split segment. At 870M with threshold 50, that's ~22k false-negatives across the env — a rounding error on a count-badge UI but a measurable bias if anyone uses the count for billing or contract decisions.
What to ship
Implement the recursion as a CASE WHEN bare_hash_mod = 9998 THEN <recursive hash> ELSE <main hash> END wrapper in the inline SQL. The recursive hash uses doubled input: seg_key || ',' || value || ',' || seg_key || ',' || value. Cap at 2-3 iterations (engine recurses arbitrarily but in practice the second iteration almost always lands at non-9998).
Why deferred
Sub-0.005% bias on a UI count is below the threshold that customers care about. Defer until a customer reports a discrepancy or until the engine's bucketing semantics change.
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-sql-flag-engine
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Dependency Dashboard Open
Difficulty 4/5 3-5 days Newbie friendliness 15/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
Flagsmith/flagsmith-sql-flag-engine#3 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in Flagsmith/flagsmith-sql-flag-engine
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100