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

fix: Unary-test expression with null value #689

Merged
merged 3 commits into from
Jul 19, 2023
Merged

Conversation

saig0
Copy link
Member

@saig0 saig0 commented Jul 18, 2023

Description

Align the behavior of unary-tests with a comparison to null. In both cases, the engine returns null.

For example, the evaluation of < 3 with null as the input value returns null. Same as the comparison null < 3 returns null.

Fixing the behavior in the parser by introducing a special case for simple-positive-unary-test (i.e. comparison with the input value).

Related issues

closes #679

saig0 added 3 commits July 18, 2023 06:36
Re-enable ignored tests cases for unary-tests comparison with null.
Fix the parsing of a positive-unary-test expression. Before all expressions were parsed as UnaryTestExpression. As a result, the interpreter evaluated the unary-test (`< 5`) and if it returned false, it compared the input value with the result of the unary-test (i.e. `< 5` => `input < 5 or input = (input < 5)` => `null < 5 or null = (null < 5)` => `null or null = null` => `true`).

For positive-unary-test comparison with the input value (e.g. `< 5`), it makes no sense to compare the result of the comparison with the input value again.

Fix the behavior in the parser by handing these case separately and give them precedence over the general unary-tests behavior.
Previously, an expression with a range returned false if the input or one of the range values was null.

Align the behavior with less/greater than comparison and return null instead.
@saig0 saig0 requested a review from remcowesterhoud July 18, 2023 06:48
Copy link
Contributor

@remcowesterhoud remcowesterhoud left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@saig0 saig0 merged commit a269369 into main Jul 19, 2023
@saig0 saig0 deleted the 679-unary-tests-with-null branch July 19, 2023 04:17
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.

Null in unary-test expressions should resolve to ValNull
2 participants