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

UPPER(MISSING) return NULL in legacy mode and MISSING in permissive mode #1241

Open
am357 opened this issue Oct 5, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@am357
Copy link
Contributor

am357 commented Oct 5, 2023

This may not be a bug

Description

UPPER (or LOWER, and perhaps similar behavior in other functions) returns NULL in legacy mode but MISSING in permissive mode. Shouldn't the function return error in legacy mode? Shouldn't we promote the MISSING to NULL in permissive mode for SQL compatibility?

From https://partiql.org/tutorial.html#_evaluating_functions_and_conditions_with_missing:

The same treatment of MISSING would happen if, say, we had this query that converts titles to capital letters:

SELECT e.id,
       e.name AS employeeName,
       UPPER(e.title) AS outputTitle
FROM hr.employeesWithMissing AS e

Again, the e.title will evaluate to MISSING for 'Bob Smith', the UPPER(e.title) is then UPPER(MISSING) and also evaluates to NULL. Thus the result will be:

<<
  {
    'id': 3,
    'employeeName': 'Bob Smith',
    'outputTitle': NULL
  },
  {
    'id': 4,
    'employeeName': 'Susan Smith',
    'outputTitle': 'DEV MGR'
  },
  {
    'id': 6,
    'employeeName': 'Jane Smith',
    'outputTitle': 'SOFTWARE ENG 2'
  }
>>

More details: https://community.partiql.org/t/partiql-tutorial-propagating-missing-in-result-tuples/114

To Reproduce

Steps to reproduce the behavior:

  1. toolbox install partiql
  2. Ensure the version is 0.13.2 by running partiql --version
  3. Run the following:
➜  ~ partiql --typing-mode PERMISSIVE
Welcome to the PartiQL shell!
Typing mode: PERMISSIVE
Using version: 0.13.2-c6bf4aec
PartiQL> UPPER(MISSING);
==='
MISSING
---
OK!

➜  ~ partiql --typing-mode LEGACY
Welcome to the PartiQL shell!
Typing mode: LEGACY
Using version: 0.13.2-c6bf4aec
PartiQL> UPPER(MISSING);
==='
NULL
---
OK!

Expected Behavior

  • We still need to investigate but perhaps the evaluator should error out in legacy mode.

Additional Context

  • PartiQL version: 0.13.2
@am357 am357 added the bug Something isn't working label Oct 5, 2023
@am357 am357 changed the title UPPER(MISSING) return NULL in legacy mode UPPER(MISSING) return NULL in legacy mode and MISSING in permissive mode Oct 5, 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