Skip to content

Fix incorrect result of approx_percentile in window operations#10368

Closed
kagamiori wants to merge 1 commit intofacebookincubator:mainfrom
kagamiori:export-D59257658
Closed

Fix incorrect result of approx_percentile in window operations#10368
kagamiori wants to merge 1 commit intofacebookincubator:mainfrom
kagamiori:export-D59257658

Conversation

@kagamiori
Copy link
Copy Markdown
Contributor

Summary:
approx_percentile(x, percentiles) returns incorrect result in a window
operation where a frame that should return non-NULL follows a frame
that returns NULL. Before the fix, the window operation returns NULL
for both frames. This is because
AggregationWindowFunction::computeAggregate() reuses the same
result vector across frames. It calls BaseVector::prepareForReuse()
before computing the aggregation for a frame. prepareForReuse()
doesn't clear the nulls buffer of the vector as it expects the code that
reuse the vector to set nulls properly. ApproxPercentileAggregate,
however, doesn't set the result rows to be non-null in the code path
for array-typed percentiles.

This diff fixes this bug by setting the nulls buffer properly.

Differential Revision: D59257658

Summary:
approx_percentile(x, percentiles) returns incorrect result in a window
operation where a frame that should return non-NULL follows a frame
that returns NULL. Before the fix, the window operation returns NULL
for both frames. This is because
AggregationWindowFunction::computeAggregate() reuses the same
result vector across frames. It calls BaseVector::prepareForReuse()
before computing the aggregation for a frame. prepareForReuse()
doesn't clear the nulls buffer of the vector as it expects the code that
reuse the vector to set nulls properly. ApproxPercentileAggregate,
however, doesn't set the result rows to be non-null in the code path
for array-typed percentiles.

This diff fixes this bug by setting the nulls buffer properly.

Differential Revision: D59257658
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 2, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Jul 2, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit d3c6856
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/66836fc75dc20b0008af8c8a

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D59257658

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in f5bfd1e.

@conbench-facebook
Copy link
Copy Markdown

Conbench analyzed the 1 benchmark run on commit f5bfd1ee.

There was 1 benchmark result indicating a performance regression:

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants