Skip to content

[GLUTEN-5682][VL] Fix incorrect result when isNull & isNotNull coexist in filter - #5670

Merged
philo-he merged 6 commits into
apache:mainfrom
zjuwangg:m_fixIsNullAndNotNull
May 13, 2024
Merged

philo-he merged 6 commits into
apache:mainfrom
zjuwangg:m_fixIsNullAndNotNull

Conversation

@zjuwangg

@zjuwangg zjuwangg commented May 9, 2024 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Fix the bug founded in issue (Fixes: #5682)

How was this patch tested?

Add ut to cover the change!

@github-actions

github-actions Bot commented May 9, 2024

Copy link
Copy Markdown

Thanks for opening a pull request!

Could you open an issue for this pull request on Github Issues?

https://github.com/apache/incubator-gluten/issues

Then could you also rename commit message and pull request title in the following format?

[GLUTEN-${ISSUES_ID}][COMPONENT]feat/fix: ${detailed message}

See also:

@FelixYBW

FelixYBW commented May 9, 2024

Copy link
Copy Markdown
Contributor

Is it only a Spark UT issue? or observed in some SQL?

@zjuwangg

zjuwangg commented May 10, 2024 •

Copy link
Copy Markdown
Contributor Author

Is it only a Spark UT issue? or observed in some SQL?

It's not just a Spark UT issue. We encounter this bug in our production environment causing result not mismatch.
We can reproduce this bug by executing following sql in VL module.
select l_orderkey from lineitem where l_comment is null and l_comment is not null

image

@zjuwangg zjuwangg changed the title [WIP][VL]isNull and isNotNull coexsit causing result not correct [GLUTEN-5682][VL]Fix isNull and isNotNull coexsit is filter causing result not correct May 10, 2024
@github-actions

Copy link
Copy Markdown

#5682

@zjuwangg

Copy link
Copy Markdown
Contributor Author

velox related change has been merged via facebookincubator/velox#9718

@zjuwangg zjuwangg changed the title [GLUTEN-5682][VL]Fix isNull and isNotNull coexsit is filter causing result not correct [GLUTEN-5682][VL]fix: isNull and isNotNull coexsit is filter causing result not correct May 10, 2024
@philo-he philo-he changed the title [GLUTEN-5682][VL]fix: isNull and isNotNull coexsit is filter causing result not correct [GLUTEN-5682][VL] Fix incorrect result when isNull & isNotNull coexsit in filter May 11, 2024

@philo-he philo-he left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your fix! Just one comment. Thanks!

Comment thread cpp/velox/substrait/SubstraitToVeloxPlan.h Outdated
@philo-he philo-he changed the title [GLUTEN-5682][VL] Fix incorrect result when isNull & isNotNull coexsit in filter [GLUTEN-5682][VL] Fix incorrect result when isNull & isNotNull coexist in filter May 11, 2024
@zjuwangg
zjuwangg requested a review from philo-he May 12, 2024 03:12
bool nullAllowed_ = false;
bool isNull_ = false;
bool forbidsNullSet_ = false;
bool isNullSet_ = false;

@philo-he philo-he May 13, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is forbidsNullSet_ logically equivalent to !nullAllowed? And isNullSet_ equivalent to isNull_? If true, we can just use the existing flags (maybe, should also check initialized_ == true?). Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually not. initialized_ can be set other place not just here two null related setter method.

@zjuwangg zjuwangg May 13, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually not. initialized_ can be set other place not just here two null related setter method.

So we can not according to initialized_ variable to determine whether setNull() or forbidsNull() has been called first.
And now setNull method will set nullAllowed_ to true that could cause unexpected filter behavior.

IMO, forbidsNullSet_ and isNullSet_ make code more clean and readable without other performance cost.

@FelixYBW FelixYBW mentioned this pull request May 13, 2024
16 of 37 tasks

@philo-he philo-he left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Thanks!

@philo-he
philo-he merged commit c8c17dd into apache:main May 13, 2024
@zjuwangg
zjuwangg deleted the m_fixIsNullAndNotNull branch September 1, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL]isNull and isNotNull both exist in filter condition, the result is not correct

3 participants