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: Verify supported type for Unary::Plus in sql planner #13019

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

eejbyfeldt
Copy link
Contributor

Which issue does this PR close?

Closes #11175.

Rationale for this change

This makes datafusion reject unary plus in more cases. This aligns our behavior with postgres and other engines by rejecting sql like select +true.

What changes are included in this PR?

This adds a type check when planning unary plus operator. Since we
currently do not represent the operator in our logical plan we can not
check it later. Instead of introducing a new Expr this patch just
verifies the type during the translation instead.

Are these changes tested?

New and existing tests.

Are there any user-facing changes?

We will no reject Unary::Plus in more cases. There is some risk that the old behavior hide bug in users code that no will cause failures.

This adds a type check when planning unary plus operator. Since we
currently do not represent the operator in our logical plan we can not
check it later. Instead of introducing a new `Expr` this patch just
verifies the type during the translation instead.
@github-actions github-actions bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Oct 20, 2024
@eejbyfeldt eejbyfeldt marked this pull request as ready for review October 20, 2024 18:30
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.

looks good to me -- thank you @eejbyfeldt

@alamb alamb merged commit 4fca0d5 into apache:main Oct 21, 2024
24 checks passed
@alamb
Copy link
Contributor

alamb commented Oct 21, 2024

Thanks again @eejbyfeldt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent behavior of '+-' arithmetic operator on Boolean type
2 participants