Null Value Manipulation

NULL values or missing data are common in data analysis. In DolphinDB, NULL values are specially designed for optimal performance. In this chapter we will explain how NULL values are expressed, initialized, and operated. We will also discuss the behavior of NULL values with normal vector functions, aggregate functions, and higher order template functions.

NULL values in DolphinDB fall into 2 categories, VOID type NULLs and NULLs of other data types (e.g., int(), double(), string(NULL)). You get a NULL of VOID type usually when using a function without return value in an assignment statement or expression. You can use the isVoid function to check if a NULL value is VOID type. Use isNull or isValid to check the existence of NULL values of any type. If you are not concerned with the data type of a NULL value, it is recommended to use isNull or isValid.

Starting from version 1.30.22, null in lowercase is supported.

typestr(NULL);
//output
VOID

isNull(null)
//output
true

def f(){
   1+2
}
typestr(f())
//output
VOID

typestr(int());
//output
INT

isVoid(NULL)
//output
true

isVoid(int())
//output
false

isNull(NULL)
//output
true

isNull(00i)
//output
true

When a calculation involves NULLs of VOID type and NULLs of a different type, the VOID NULLs will be converted to the other type.

$ int()==NULL
true
$ in(1 00f NULL 1.3, 00f) == [false, true, true, false]
[true,true,true,true]