← Back to Pull requests

fix: preserve cached rows matching a malformed UTF-8 prefix #7721

Closed
unknown closed this pull request without merging on Dec 01, 2026 01:44 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 22:20 UTC
Author

Which issue does this PR close?

Part of #6834. This follows up on the cache pruning work in #5543 under #5487.

The draft backport to branch-1.2 is #7786.

Rationale for this change

startswith(s, CAST(X'C3' AS STRING)) matches é because Spark compares the prefix byte C3 with the first byte of C3 A9. Spark's cache pruner takes one character from each batch bound for this prefix. If the lower bound is é, that gives C3 A9, which sorts after C3. The scan skips a matching batch before Spark can apply the row filter. All the cached strings can be valid UTF-8. Row comparison · Cache pruning rule

What changes are included in this PR?

When building the batch filter, Comet rewrites startswith on a binary-collated string column with a malformed UTF-8 literal as a byte range. For C3, every matching string falls in [C3, C4). Spark can skip a batch if its maximum is below C3 or its minimum is at least C4, and combine those checks with other predicates under AND and OR. The original startswith evaluates the surviving rows.

The exclusive upper bound comes from incrementing the last byte below FF and truncating after it. For example, the upper bound for C3 FF is C4. An all-FF prefix needs only the lower bound.

How are these changes tested?

CometInMemoryCachePruningSuite compares the IDs returned by startswith(s, CAST(X'C3' AS STRING)) OR id = 0 against Spark's answer collected before caching. The expected result contains ID 0 and the four IDs whose string is é. The scan metric must report eight decoded rows, exactly the two relevant four-row batches out of sixteen. The suite exercises native Arrow, Spark columnar, and row inputs.

A second SQL test caches raw strings and checks that prefixes C3 FF FF and FF FF each retain their matching row.

git diff --check and Spotless passed for the changed files. The SQL tests are submitted to hosted CI.

Diff: 275 lines (+206 / -69) across 3 files Reviewer: viirya Review duration: 14603m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 275 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.336
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7721"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.6% (MEDIUM) · Higher = larger blast radius
39.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.6% · Safe to merge
15.6%