Skip to content
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

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

Merged
merged 6 commits into from May 13, 2024

Conversation

zjuwangg
Copy link
Contributor

@zjuwangg zjuwangg commented May 9, 2024

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!

Copy link

github-actions bot commented May 9, 2024

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
Copy link
Contributor

FelixYBW commented May 9, 2024

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

@zjuwangg
Copy link
Contributor Author

zjuwangg commented May 10, 2024

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
Copy link

#5682

@zjuwangg
Copy link
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
Copy link
Contributor

@PHILO-HE PHILO-HE left a comment

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!

cpp/velox/substrait/SubstraitToVeloxPlan.h Outdated Show resolved Hide resolved
@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
@@ -375,6 +377,8 @@ class SubstraitToVeloxPlanConverter {

bool nullAllowed_ = false;
bool isNull_ = false;
bool forbidsNullSet_ = false;
bool isNullSet_ = false;
Copy link
Contributor

@PHILO-HE PHILO-HE May 13, 2024

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
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.

Copy link
Contributor Author

@zjuwangg zjuwangg May 13, 2024

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.

Copy link
Contributor

@PHILO-HE PHILO-HE left a comment

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
41 checks passed
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