Semantics of Special Values

 This section describes the behavior of empty cells, the SciDB-specific special value missing, and IEEE floating-point special values NaN, inf, and -inf.

Here are some definitions.

  • ?m – denotes a missing value, with non-negative integer m representing the missing reason code.
  • null – defined as ?0, a special case of missing.
  • op() – denotes a unary or binary expression or function, such as x + y, x < y, or sin(x).
  • Empty – denotes an operand that would ordinarily come from a cell at a particular position, but that cell is empty — that is, no cell exists at that position.
  • An aggregator is a function or operator that computes aggregates, such as count().
  • A floating point value is a SciDB attribute of type float or double. In this section, it is restricted to "normal" floating-point values (such 1.4, -3.75, and so on), plus NaN, +inf, and -inf, but does not include empty nor missing.

op() as a Binary Logical Operator

When op() is logical AND or logical OR SciDB follows SQL three-valued logic rules, modified to propagate missing reasons codes when possible.  Specifically:

  • op(?m, ?n) returns ?0 (null) since their is no basis for choosing between ?m and ?n.
  • op(x, ?m) (or op(?m, x)) returns ?m, unless the missing value would not affect the result.  Specifically, OR(?m, true) returns true, and AND(?m, false) returns false.

op() as a Function or Expression Operator

When op() is a function or expression operator...

  • if at least one operand is empty, the result is empty.
  • if at least one of x or y is missing (?m), but neither is empty: op(x,y) returns ?0 (but see above for logical Boolean operators).
  • if the value for a unary operator is missing but not empty, op(?m) returns ?m.
  • if at least one of the floating point values x or y is NaN:
    • When op(x,y) is a comparison expression: x {==,<,>,<=,>=} y returns FALSE, and x <> y returns TRUE
    • When op(x,y) is not a comparison expression: op(x,y) and op(NaN) both return NaN.

op() as an Aggregate

An SciDB aggregator is an operator that aggregates values using aggregate functions.  When op() is an aggregate function:

  • Empty cells do not participate in aggregation, they are ignored.
  • Aggregators handle missing attributes differently depending on the aggregate function.
  • NaN is included during aggregation. For example, the sum of a set of double numbers is NaN if one or more of those numbers is NaN.

Whenever possible, SciDB computations adhere to the IEEE Standard for Floating-Point Arithmetic (IEEE 754). Exceptions are documented in the appropriate place for the specific operator or function.

The sort() Operator

When using the sort() operator, special values follow the sort order:

?m < NaN < x

where:

  • '<' indicates comes before
  • For missing values, the sort order is based on the value of the missing code. Thus, ?0 comes before ?10 which comes before ?72.
  • x represents any floating point number, other than NaN.