Null 處理
SQL has an unconventional way of handling NULL values, since it treats them as unknown values. As a result, in SQL:
NULLis not a value indicating a missing entry, but a placeholder for anything possible,NULL = NULLevaluates toNULL, since one cannot know if one unknown is equal to another unknown,NULL <> NULLevaluates toNULL, using same logic,- to check if a value is
NULL, SQL introducesIS NULLandIS NOT NULLoperators, DISTINCT columnmay return multipleNULLvalues.
For more information, check out the Postgres documentation.
PRQL, on the other hand, treats null as a value, which means that:
null == nullevaluates totrue,null != nullevaluates tofalse,- distinct column cannot contain multiple
nullvalues.
PRQL
from employees
filter first_name == null
filter null != last_name
SQL
SELECT
*
FROM
employees
WHERE
first_name IS NULL
AND last_name IS NOT NULL
Note that PRQL doesn’t change how NULL is compared between columns, for example in joins. (PRQL compiles to SQL and so can’t change the behavior of the database).
For more context or to provide feedback check out the discussion on issue #99.