Skip to main content

Categories: Boolean, Datatype

IS [NOT] DISTINCT FROM

Compares two expressions to determine whether they have the same or different values. IS DISTINCT FROM returns TRUE if the values are different, and IS NOT DISTINCT FROM returns TRUE if they are the same. Unlike <> and =, they treat two NULL values as the same and never return NULL.

Syntax​

IS [NOT] DISTINCT FROM(expression1 any, expression2 any) → boolean​

  • expression1: First expression. Can be a general expression of any Dremio-supported data type.
  • expression2: Second expression. Can be a general expression of any Dremio-supported data type.

Examples

IS [NOT] DISTINCT FROM example
SELECT NULL IS DISTINCT
FROM NULL
-- False
IS DISTINCT FROM with different values
SELECT 1 IS DISTINCT FROM 2
-- true
IS DISTINCT FROM with the same value
SELECT 1 IS DISTINCT FROM 1
-- false
IS DISTINCT FROM with a NULL value
SELECT 1 IS DISTINCT FROM NULL
-- true
IS DISTINCT FROM with strings
SELECT 'Dremio' IS DISTINCT FROM 'Cloud'
-- true
IS [NOT] DISTINCT FROM example
SELECT NULL IS NOT DISTINCT
FROM NULL
-- True
IS NOT DISTINCT FROM with the same value
SELECT 1 IS NOT DISTINCT FROM 1
-- true
IS NOT DISTINCT FROM with different values
SELECT 1 IS NOT DISTINCT FROM 2
-- false
IS NOT DISTINCT FROM with a NULL value
SELECT 1 IS NOT DISTINCT FROM NULL
-- false