fix: Fix presto bias fuzzer test error#16718
fix: Fix presto bias fuzzer test error#16718lifulong wants to merge 1 commit intofacebookincubator:mainfrom
Conversation
✅ Deploy Preview for meta-velox canceled.
|
eafb7bf to
3235dff
Compare
|
@lifulong Can you add more details in the issue or this PR. Which function was bias fuzzer testing, do you have a link to bias fuzzer run ? Is the bug in from_big_endian_32 or is it in fuzzer ? From your PR it appears in the fuzzer ? |
|
/claude-review Look at issue #16712 , also look at the provided solution here. Is the bug in expression fuzzer ? Give a deep analysis on cause of failure and how this fixes it. |
✅ Claude Code ReviewRequested by @kgpai This fix is well-designed and necessary. It correctly addresses the root cause of the fuzzer test failure by ensuring both evaluation paths operate on identical expression trees, thus making the comparison meaningful and the test robust. ℹ️ About this responseThis review was generated by Claude Code. It analyzed the PR diff and codebase to provide feedback. Limitations:
Available commands:
|
|
/claude-review Look at issue #16712. Do an analysis on cause of problem. Subsequently review the code here. Is the bug in expression fuzzer ? Give a deep analysis on cause of failure and how this fixes it. Give examples when possible. Do not give terse responses, give a detailed thorough response. |
✅ Claude Code ReviewRequested by @kgpai Now I have a good understanding of the issue. Let me create a comprehensive analysis: Deep Analysis of the Presto Bias Fuzzer Test FixSummaryThis pull request fixes a subtle but critical issue in the Root Cause AnalysisThe Problem: The bias fuzzer tests compare the results of two evaluation paths:
Key Issue: These were different compiled expression trees:
Critical Problems with the Old Code:1. Different Expression Optimizations Applied// OLD CODE - PROBLEMATIC:
exec::ExprSet exprSetCommon =
createExprSetCommon(plans, execCtx_, options_.disableConstantFolding); // Has custom optimization settings
exec::ExprSetSimplified exprSetSimplified(plans, execCtx_); // Default settings, different optimizationsThe
2. False Positive Test FailuresWhen the fuzzer detected differences between the two paths, it was unclear if this indicated:
3. Testing Different Things Instead of Same ThingThe fuzzer's purpose is to test that:
But it was actually testing:
The Fix ExplainedThe fix addresses this by ensuring both paths use the exact same compiled expression tree: // NEW CODE - CORRECT:
exec::ExprSet exprSetCommon =
createExprSetCommon(plans, execCtx_, options_.disableConstantFolding);
// Remove the separate ExprSetSimplified - deleted this line:
// exec::ExprSetSimplified exprSetSimplified(plans, execCtx_);In the simplified evaluation section: // OLD CODE:
exec::EvalCtx evalCtxSimplified(execCtx_, &exprSetSimplified, rowVector.get());
exprSetSimplified.eval(0, exprSetSimplified.size(), true, rows, evalCtxSimplified, simplifiedEvalResult);
// NEW CODE:
exprSetCommon.clear(); // Clear cached state
simplifiedEvalResult.resize(exprSetCommon.size());
exec::EvalCtx evalCtxSimplified(execCtx_, &exprSetCommon, rowVector.get());
for (int32_t i = 0; i < exprSetCommon.size(); ++i) {
exprSetCommon.exprs()[i]->evalSimplified(rows, evalCtxSimplified, simplifiedEvalResult[i]);
}Why This Fix Works1. Same Expression Tree, Different Evaluation Methods
2. Proper State ManagementexprSetCommon.clear(); // Clears shared subexpressions and memoization cacheThe
3. Individual Expression Evaluationfor (int32_t i = 0; i < exprSetCommon.size(); ++i) {
exprSetCommon.exprs()[i]->evalSimplified(rows, evalCtxSimplified, simplifiedEvalResult[i]);
}Instead of using the batch Edge Cases and CorrectnessMemory Safety 🟢
Concurrency Safety 🟢
Error Handling 🟢
State Management 🟢
Examples of Issues This FixesExample 1: CoalesceRewrite Inconsistency-- Expression: COALESCE(NULL, column_a, column_b)Before (Problematic):
After (Fixed):
Example 2: Constant Folding Differences-- Expression: column_a + (5 * 10)Before (Problematic):
After (Fixed):
Performance ImplicationsPositive Impact 🟢
Minimal Overhead 🟢
Issues Found🟢 Positive Observations
🟡 Minor Suggestions
ConclusionThis is a high-quality fix that addresses a fundamental issue in the expression fuzzer testing framework. The change ensures that both evaluation paths operate on identical compiled expression trees, eliminating false positives caused by different optimizations being applied. The fix is minimal, safe, and maintains the original test intentions while improving accuracy and reliability of the bias fuzzer tests. The fix demonstrates deep understanding of the Velox expression evaluation system and properly addresses the root cause rather than applying a surface-level patch. This should significantly improve the effectiveness of the Presto bias fuzzer in catching real evaluation bugs while reducing noise from optimization differences. ℹ️ About this responseThis review was generated by Claude Code. It analyzed the PR diff and codebase to provide feedback. Limitations:
Available commands:
|
| std::vector<VerificationState> verificationStates; | ||
| // Share ExpressionSet between consecutive iterations to simulate its usage in | ||
| // FilterProject. | ||
| // Use the same compiled Expr tree (exprSetCommon) for the simplified path, |
There was a problem hiding this comment.
Expression fuzzer is meant to test out the optimizations thus if it uses the same expression tree this test is rendered moot.
Can you add a deeper analysis on issue before making this change.
There was a problem hiding this comment.
I don’t really get the original idea behind the fuzzer test module.
I thought its main purpose was just to make sure we handle input formats like lazy and dictionary encoding correctly.
I figured as long as the common path and simplified path take different input formats, that would be enough for testing.
But if the goal is also — or even mainly — to test execution plan optimizations, then this change really isn’t suitable. I will make this pr as draft and close it later.
The full issue and reproduction steps are described in (#16712)
You can reproduce it reliably using random seed 3827.
|
the sql format for test plan is |
fix #16712