Null Value Operations
Generally, if a null value is one of the arguments of a function/operator, the result would be null.
x = 1.0 + 5.6 * 3 + NULL + 3
isNull(x)
// output: 1
typestr x;
// output: DOUBLE
However, there are special cases as follows:
- With comparison operators >, >=, <, <=, and between, null values represent the
minimum value when the configuration parameter nullAsMinValueForComparison is
set to true (default). When it is set to false, the comparison result is
null.
// nullAsMinValueForComparison = true 1 < NULL // output: false 1 > NULL // output: true // nullAsMinValueForComparison = false 1 < NULL // output: 00b 1 > NULL // output: 00b
- With comparison operators !=, <>, and ==, null values represent the minimum value
and two null values are considered
equal.
NULL == NULL // output: true NULL != NULL // output: false
- In the
or
function, if only one operand is null, the result is equal to the other non-null operand when the configuration parameter logicOrIgnoreNull is set to true (default). When it is set to false, the result is null is one operand is null.// logicOrIgnoreNull = true NULL or true // output: true NULL or false // output: false NULL or NULL // output: 00b // logicOrIgnoreNull = false NULL or true // output: 00b NULL or false // output: 00b NULL or NULL // output: 00b
- In aggregate functions such as
sum
/avg
/med
, null values are ignored.x = 1 2 NULL NULL 3; sum(x) // output: 6 avg(x) // output: 2
- When sorting elements in a vector, null values represent the minimum value.
- In functions
ols
/olsEx
/corrMatrix
/olsEx
, null values in parameters are replaced with 0.