-
Couldn't load subscription status.
- Fork 239
Open
Labels
language-designChanges to PRQL-the-languageChanges to PRQL-the-languageneeds-discussionUndecided dilemmaUndecided dilemma
Description
What happened?
PRQL is not consistent with null comparisons, it transforms == null and != null to IS NULL and IS NOT NULL, yet does not emit similar things for two column comparisons.
Given that == is already null safe in some contexts, it should also be null-safe in others, I.e using
- SQL's IS NOT DISTINCT FROM (Feature T151 of SQL:1999)
- MySQL's: <=> (https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_equal-to)
Sqlite's IS (https://www.sqlite.org/lang_expr.html#isisnot)it also supports standardIS NOT DISTINCT FROM- (Every other database implements standard IS NOT DISTINCT FROM)
PRQL input
prql target:sql.postgres
from test
derive {
a == "a",
a == b,
a == null && b == null
}SQL output
SELECT
*,
a = 'a', -- Ok: nothing wrong will happen if a is NULL
a = b, -- Error: Wrong result if a and b is NULL
a IS NULL
AND b IS NULL
FROM
testExpected SQL output
SELECT
*,
a = 'a',
a IS NOT DISTINCT FROM b, -- Ok: We don't know if a or b might be NULL, so we need to be strict here
a IS NULL
AND b IS NULL
FROM
testMVCE confirmation
- Minimal example
- New issue
Anything else?
No response
JarvisCraft, max-sixty and snth
Metadata
Metadata
Assignees
Labels
language-designChanges to PRQL-the-languageChanges to PRQL-the-languageneeds-discussionUndecided dilemmaUndecided dilemma