GH-55614: [C++][Gandiva] Build the expression cache key from the expression tree #55608
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 304 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.342
Real PR Conversation Timeline
1 comments
"Review active on #55608"
general
weight: 0.35
kou
Rationale for this change
The cache key is built from
Expression::ToString(). Different expressions can print the same text, so the secondProjector::Makereuses the compiled code of the first. The result is wrong, with no error. Four cases on main:a AND (b OR c)and(a AND b) OR cprint the same text.IFexpressions can print the same text.int64output skips validation after anint32one was compiled, and returns garbage.Make, but accepted when a valid one was compiled before.What changes are included in this PR?
The PR has the tests first, then the fix in
expression_cache_key.h.The fix builds the key with a visitor over the expression tree, with the output field type. It is a compact binary form. Every node starts with a tag, tokens carry their length, and child lists carry their count. Types and names that repeat are written once and then as a short reference. It also sorts
INlists and findslikeby node, not by text. The key handles null child nodes, so it no longer crashes before validation.Are these changes tested?
Yes. 15 new tests: key unit tests in
cache_test.cc, and end-to-end tests forProjectorandFilterinprojector_test.cc,filter_test.cc,boolean_expr_test.cc,if_expr_test.ccandprojector_build_validation_test.cc. They cover the cases above,INvalue lists, type parameters, floating point literals, null child nodes, and two schemas that differ only in nullability.On main, 12 of them fail (one crashes with SIGSEGV). Three pass on both keys:
FloatingPointBitsAndNulls, because float and double literals already print their bits, and the two tests for schemas that differ only in nullability, which record current behavior.See the comments for the time to build the key and its size.
Are there any user-facing changes?
No.
This PR contains a "Critical Fix". It fixes a bug that returned incorrect data without an error.
Was AI used for this PR?
AI tools helped investigate the bug and write the fix, tests, and description.
PR code and description written by:
Reviewed before submission by: