Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

NULL type

The null value represents the absence of a value. It is different from an empty string, the number 0, or an empty container. NebulaGraph Database Developer Edition uses the NULL type during expression type inference when a null value does not yet have a specific material type.

The NULL type is an immaterial value type and cannot be used as a node or edge property type.

View the NULL type

Use the typeof() function to view the type of a NULL expression:

RETURN typeof(NULL)

Return:

+--------------+
| typeof(NULL) |
+--------------+
| NULL         |
+--------------+

NULL type, null value, and nullability

Concept Example Meaning
NULL type typeof(NULL) The type inferred for a standalone NULL expression when no more specific type can be determined from the context
Null value name = NULL Indicates that no value is currently present
Nullable type name STRING DEFAULT NULL The storage location permits a null value
Non-nullable type id INT64 NOT NULL The storage location does not permit a null value

For example:

'''
VALUE name STRING = NULL
RETURN typeof(name), name
'''

+--------------+------+
| typeof(name) | name |
+--------------+------+
| STRING       | null |
+--------------+------+

The declared type of name is STRING, and its current value is NULL. A null value does not change the declared type of a variable or property to NULL.

The same distinction applies to properties:

NODE Person (
  LABEL Person {
    id INT64 NOT NULL,
    name STRING DEFAULT NULL,
    PRIMARY KEY (id)
  }
)

The type of the name property is STRING, and DEFAULT NULL specifies its default value. You cannot declare a property as name NULL.

Uses of the NULL type

The NULL type is primarily used for expression type inference. A standalone NULL expression does not contain enough information to determine whether it represents a string, number, or date. When it is used in a context with a specific type, the system handles the null value according to that context.

NULL can also occur in container expressions such as lists, sets, and maps. When a container also contains non-null values, the system uses those values to infer the container element type.

Note

Use IS NULL or IS NOT NULL to test for a null value. Do not use an ordinary equality comparison.