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

Truth Value Handling in the Typer #1278

Open
yliuuuu opened this issue Dec 1, 2023 · 0 comments
Open

Truth Value Handling in the Typer #1278

yliuuuu opened this issue Dec 1, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@yliuuuu
Copy link
Contributor

yliuuuu commented Dec 1, 2023

Description

  • Truth value handling in the PlanTyper is still buggy.

For example:
Consider:

CASE WHEN NULL THEN 1 ELSE 0 END

This returns:

ERROR : null is/are incompatible data types for the 'CASE_WHEN' operator.

According to SQL spec, the case expression should returns the value of the of the first (leftmost)
whose is true.

Per my understand, NULL should be permitted in the case expression, as NULL IS TRUE simply returns false.

See also: PostgreSQL link.

This will be a problem for us, practically because we rewrite control flow function like NULLIF to case when.

i.e.,

NULLIF(a, b)
-- is equivalent to  
CASE WHEN a=b THEN NULL ELSE a END -- a=b can return null. 

To Reproduce

CASE WHEN NULL THEN 1 ELSE 0 END
java.lang.AssertionError: ERROR:null is/are incompatible data types for the 'CASE_WHEN' operator.

Expected Behavior

Define a better handling mechanism for truth value in the typer.

Additional Context

  • Java version: XXX
  • PartiQL version: 0.13.2
  • Add any other context about the problem here.
@yliuuuu yliuuuu added the bug Something isn't working label Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant