Skip to content

Commit d31fd29

Browse files
authored
docs: clarify semantics of *Null* value (#842)
1 parent 1aa2bcd commit d31fd29

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/docs/core/data_types.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,22 @@ Currently, the following types are key types
199199
- *Uuid*
200200
- *Date*
201201
- *Struct* with all fields being key types (using `@dataclass(frozen=True)` or `NamedTuple`)
202+
203+
## *Null* Values
204+
205+
CocoIndex supports *Null* values. A *Null* value represents the absence of data or an unknown value, distinct from empty strings, zero numbers, or false boolean values.
206+
207+
### Nullable Data
208+
209+
For any data (e.g. a field of a *Struct*, an argument or return value of a CocoIndex function), if it is nullable, it means its value can be *Null*.
210+
211+
In Python, *Null* is represented as `None`, so a nullable type can be represented by `T | None` or `typing.Optional[T]`.
212+
213+
### *Null* propagating on CocoIndex functions
214+
215+
A function may specify whether each input argument is nullable or not.
216+
Non-nullable argument means the function needs a known value for the argument to work.
217+
However, it doesn't forbid the argument to be *Null* at runtime.
218+
When a non-nullable argument receives a *Null* value, the function execution is skipped and the result is *Null*.
219+
220+
For example, for [`SplitRecursively` function](/docs/ops/functions#splitrecursively), the `text` and `chunk_size` arguments are not nullable. If the input value of either of them is *Null*, the function will return *Null*.

0 commit comments

Comments
 (0)