Skip to content

Conversation

@jonahgao
Copy link
Member

Which issue does this PR close?

Closes #11846.

Rationale for this change

The initial value of each group was set to false. When encountering the first non-null value of a certain group and performing the AND operation with the initial value, it resulted in an incorrect output.

We should set the initial value to the identity element.

What changes are included in this PR?

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Aug 15, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

Thank you @jonahgao

cc @2010YOUY01

self.values.append_n(new_groups, Default::default());
// Fill with the identity element, so that when the first non-null value is encountered,
// it will combine with the identity and the result will be the first non-null value itself.
self.values.append_n(new_groups, self.identity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice -- this is similar to the default value for the PrimitiveOp accumulator too

Copy link
Contributor

@Dandandan Dandandan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dandandan Dandandan merged commit 5db036e into apache:main Aug 16, 2024
@jonahgao jonahgao deleted the fix_bool_aggr branch August 16, 2024 09:16
@jonahgao
Copy link
Member Author

Thanks for the review.

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

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential bug in bool_and() aggregate function

3 participants