Skip to content

feat: Convert IS TRUE|FALSE to expression #499

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

Merged
merged 1 commit into from
May 24, 2022

Conversation

ovr
Copy link
Contributor

@ovr ovr commented May 17, 2022

Hello!

Support for IS TRUE|FALSE operator was introduced in #474 by yuval-illumex, but it has a limitation.

There is a difference between IS TRUE|false and = true|false, it how it handles nulls:

CREATE TABLE test_boolean (
    col boolean
);
INSERT INTO test_boolean VALUES (true), (false), (null);
SELECT col, col IS FALSE, col = false, col is true, col = true from test_boolean;

image

As you can see from the output, it handles null values differently.

Thanks

@ovr ovr force-pushed the is-boolean-upstream branch from e792bad to f7ac96f Compare May 17, 2022 18:55
@coveralls
Copy link

coveralls commented May 17, 2022

Pull Request Test Coverage Report for Build 2370698249

  • 14 of 15 (93.33%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.005%) to 89.822%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tests/sqlparser_common.rs 8 9 88.89%
Files with Coverage Reduction New Missed Lines %
tests/sqlparser_common.rs 1 97.01%
Totals Coverage Status
Change from base Build 2367540025: 0.005%
Covered Lines: 8322
Relevant Lines: 9265

💛 - Coveralls

@ovr ovr force-pushed the is-boolean-upstream branch from f7ac96f to d0c80f5 Compare May 17, 2022 19:00
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.

I am not a huge fan of the growing number of Expr::Is* variants, but that is not something introduced in this PR.

@@ -236,6 +236,10 @@ pub enum Expr {
expr: Box<Expr>,
key: Ident,
},
/// `IS FALSE` operator
Copy link
Contributor

Choose a reason for hiding this comment

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

It is somewhat unfortunate we don't have Expr::Is(Box<Expr>, Box<Expr>) which would handle all these cases.

What do you think @ovr ? Should I file a ticket to try and reduce the duplication in Expr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO: It's a breaking change, which doesn't give any advantages over this. Right now, it's really easy to implement a match pattern over this because names are really helpful.

@alamb
Copy link
Contributor

alamb commented May 22, 2022

Screen Shot 2022-05-22 at 3 41 24 PM

@ovr github tells me there is a conflict to resolve in this PR -- I haven't been able to fix such issues in the past as I don't have the ability to push commits to your PR

Can you please resolve the conflicts, and then I will merge this PR?

Thank you!

@ovr ovr force-pushed the is-boolean-upstream branch from d0c80f5 to dbc2486 Compare May 23, 2022 10:42
@ovr
Copy link
Contributor Author

ovr commented May 23, 2022

Rebased ✅

@alamb alamb merged commit 4070f3e into apache:main May 24, 2022
@alamb
Copy link
Contributor

alamb commented May 24, 2022

Thanks @ovr

@ovr ovr deleted the is-boolean-upstream branch May 24, 2022 13:27
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.

3 participants