-
Notifications
You must be signed in to change notification settings - Fork 248
[Bug] Handle zero filter damping in ORCA conjunctions #2007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -502,12 +502,25 @@ CScaleFactorUtils::CalcScaleFactorCumulativeConj( | |
|
|
||
| const ULONG num_cols = scale_factors->Size(); | ||
| CDouble scale_factor(1.0); | ||
| if (0 == num_cols) | ||
| { | ||
| return scale_factor; | ||
| } | ||
|
|
||
| if (1 < num_cols) | ||
| { | ||
| // sort (in desc order) the scaling factor based on the selectivity of each column | ||
| scale_factors->Sort(CScaleFactorUtils::DescendingOrderCmpFunc); | ||
| } | ||
|
|
||
| if (CDouble(0.0) == stats_config->DDampingFactorFilter()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this branch computes exactly what the loop below already computes when the damping factor is 0, so it does not change behavior:
Empirically,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, the comment "Handle zero explicitly rather than relying on CDouble's minimum magnitude when computing powers" is excessive. But can we keep this branch as a quick way to return from the function to avoid the (unnecessary in this situation) loop below? |
||
| { | ||
| // Maximum overlap: retain only the smallest selectivity, represented | ||
| // by the largest scale factor. Handle zero explicitly rather than | ||
| // relying on CDouble's minimum magnitude when computing powers. | ||
| return std::max(CStatistics::MinRows.Get(), (*scale_factors)[0]->Get()); | ||
| } | ||
|
|
||
| for (ULONG ul = 0; ul < num_cols; ul++) | ||
| { | ||
| // apply damping factor | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this reachable? The only caller (
CFilterStatsProcessor::MakeHistHashMapConjFilter) unconditionally appendslast_scale_factorbefore calling, soSize() >= 1, and the pre-existing loop already returned 1.0 for zero iterations. It seems to exist only to guard the new(*scale_factors)[0]below. If the zero branch is kept, the siblingCalcScaleFactorCumulativeDisjexpresses the same precondition asGPOS_ASSERT(0 < num_cols), which may be the more consistent form.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right,
GPOS_ASSERT(0 < num_cols)will be better for the current usage of this function. We always add one element to thescale_factorsarray before callingCalcScaleFactorCumulativeConj, so for the possible future changes from other contributors it will be better to express our expectations withGPOS_ASSERT.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at #2006 I reuse
CalcScaleFactorCumulativeConjthere and it's possible that there will be no outer predicates, so in this case I expectCalcScaleFactorCumulativeConjwill return 1.0. This checkif (0 == num_cols)appears due to the reusage of this function in #2006.