Skip to content

docs: clarify nullability for builtin function argument types #843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/docs/core/data_types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ Currently, the following types are key types

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.

### Nullable Data
### Nullable Type

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*.
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*.
We use a `?` suffix to indicate a nullable type, e.g. *Str?*, *Person?*.

In Python, *Null* is represented as `None`, so a nullable type can be represented by `T | None` or `typing.Optional[T]`.

Expand Down
18 changes: 9 additions & 9 deletions docs/docs/ops/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ description: CocoIndex Built-in Functions

`ParseJson` parses a given text to JSON.

The spec takes the following fields:
Input data:

* `text` (`str`): The source text to parse.
* `language` (`str`, optional): The language of the source text. Only `json` is supported now. Default to `json`.
* `text` (*Str*): The source text to parse.
* `language` (*Str?*, default: `"json"`): The language of the source text. Only `json` is supported now.

Return: *Json*
Return: *Json*, the parsed JSON object.

## SplitRecursively

Expand All @@ -37,7 +37,7 @@ Input data:

* `text` (*Str*): The text to split.
* `chunk_size` (*Int64*): The maximum size of each chunk, in bytes.
* `min_chunk_size` (*Int64*, optional): The minimum size of each chunk, in bytes. If not provided, default to `chunk_size / 2`.
* `min_chunk_size` (*Int64*, default: `chunk_size / 2`): The minimum size of each chunk, in bytes.

:::note

Expand All @@ -48,8 +48,8 @@ Input data:

:::

* `chunk_overlap` (*Int64*, optional): The maximum overlap size between adjacent chunks, in bytes.
* `language` (*Str*, optional): The language of the document.
* `chunk_overlap` (*Int64?*, default: *Null*): The maximum overlap size between adjacent chunks, in bytes.
* `language` (*Str*, default: `""`): The language of the document.
Can be a language name (e.g. `Python`, `Javascript`, `Markdown`) or a file extension (e.g. `.py`, `.js`, `.md`).


Expand All @@ -61,7 +61,7 @@ Input data:
* `custom_languages` in the spec, against the `language_name` or `aliases` field of each entry.
* Builtin languages (see [Supported Languages](#supported-languages) section below), against the language, aliases or file extensions of each entry.

All matches are in a case-insensitive manner. If the value of `language` is null, it'll be treated as empty string.
All matches are in a case-insensitive manner.

* If no match is found, the input will be treated as plain text.

Expand Down Expand Up @@ -185,7 +185,7 @@ Not all LLM APIs support text embedding. See the [LLM API Types table](/docs/ai/

Input data:

* `text` (*Str*, required): The text to embed.
* `text` (*Str*): The text to embed.

Return: *Vector[Float32, N]*, where *N* is the dimension of the embedding vector determined by the model.

Expand Down