Tables and data
- group Tables and data
Create tables, write and read data, inspect schemas, and change metadata.
Enums
-
enum LanceDBCreateTableMode
Create table modes for lancedb_table_create_with_options().
The values mirror the LanceDB SDK’s CreateTableMode. Create returns LANCEDB_TABLE_ALREADY_EXISTS when the table exists, Overwrite replaces it with the supplied data, and ExistOk opens the existing table and ignores the supplied data. ExistOk schema and reopen behavior is backend-dependent:
A root listing connection compares the existing table schema with the request schema (the reader schema when a reader is supplied, otherwise schema_ptr) and reopens through the SDK ExistOk callback. This binding supplies the custom location and per-table storage options to that callback so a same-name default table is not opened instead.
Nonempty namespace paths and direct namespace connections ask the namespace backend to open the existing table; the pinned SDK does not call the C callback or compare schemas on that path.
The remote client compares the schema only on its AlreadyExists reopen path.
Values:
-
enumerator LANCEDB_CREATE_TABLE_MODE_CREATE
-
enumerator LANCEDB_CREATE_TABLE_MODE_OVERWRITE
-
enumerator LANCEDB_CREATE_TABLE_MODE_EXIST_OK
-
enum LanceDBWriteOptionsField
Fields of LanceDBWriteOptions.
Every bit makes the matching field an override. A field whose bit is not set keeps the LanceDB SDK default, so an omitted option stays distinct from an explicit zero or false.
Values:
-
enumerator LANCEDB_WRITE_OPTIONS_MAX_ROWS_PER_FILE
-
enumerator LANCEDB_WRITE_OPTIONS_MAX_ROWS_PER_GROUP
-
enumerator LANCEDB_WRITE_OPTIONS_MAX_BYTES_PER_FILE
-
enumerator LANCEDB_WRITE_OPTIONS_DATA_STORAGE_VERSION
-
enumerator LANCEDB_WRITE_OPTIONS_ENABLE_STABLE_ROW_IDS
-
enumerator LANCEDB_WRITE_OPTIONS_MAX_ROWS_PER_FILE
-
enum LanceDBAddDataMode
Add-data modes for lancedb_table_add_with_options().
Append keeps the existing rows. Overwrite replaces the table contents with the supplied data.
Values:
-
enumerator LANCEDB_ADD_DATA_MODE_APPEND
-
enumerator LANCEDB_ADD_DATA_MODE_OVERWRITE
-
enumerator LANCEDB_ADD_DATA_MODE_APPEND
-
enum LanceDBNaNVectorBehavior
How an add treats NaN and null elements in vector columns.
Error is the SDK default and rejects such vectors. Keep stores them, but they are not indexed for search. Whole null vectors are allowed by both modes.
Values:
-
enumerator LANCEDB_NAN_VECTOR_BEHAVIOR_ERROR
-
enumerator LANCEDB_NAN_VECTOR_BEHAVIOR_KEEP
-
enumerator LANCEDB_NAN_VECTOR_BEHAVIOR_ERROR
-
enum LanceDBAddOptionsField
Fields of LanceDBAddOptions.
Every bit makes the matching field an override. A field whose bit is not set keeps the LanceDB SDK default, so an omitted retry or write parallelism stays distinct from an explicit zero.
Values:
-
enumerator LANCEDB_ADD_OPTIONS_RETRIES
-
enumerator LANCEDB_ADD_OPTIONS_WRITE_PARALLELISM
-
enumerator LANCEDB_ADD_OPTIONS_RETRIES
-
enum LanceDBUpdateField
Update option fields of LanceDBUpdateOptions.
Every bit makes the matching field an override. A field whose bit is not set keeps the LanceDB default, so an omitted retry stays distinct from an explicit zero retry budget.
Values:
-
enumerator LANCEDB_UPDATE_RETRIES
-
enumerator LANCEDB_UPDATE_RETRIES
Functions
-
void lancedb_table_free(LanceDBTable *table)
Free a Table.
After calling this function, the table pointer must not be used.
- Parameters:
table – - pointer to LanceDBTable returned from lancedb_connection_open_table()
-
void lancedb_run_on_stack(void (*callback)(void*), void *user_data, size_t red_zone, size_t stack_size)
Run a callback on an extended stack.
If the remaining stack is below red_zone bytes, a new stack segment of stack_size bytes is allocated before calling the callback. Use this to wrap coroutine bodies so that inner FFI calls can reuse the same stack segment instead of allocating one per call.
The callback must not unwind across the FFI boundary (no C++ exceptions, no longjmp). In C++ code, wrap the callback body in try/catch. Using an extern “C” function is recommended, though a non-capturing lambda will compile on all major compilers as well.
- Parameters:
callback – - function pointer to call on the extended stack (NULL is a safe no-op)
user_data – - opaque pointer passed through to the callback
red_zone – - minimum remaining stack (bytes) before growing
stack_size – - size of the new stack segment (bytes) if growth is needed (clamped to at least red_zone)
-
LanceDBError lancedb_table_create(const LanceDBConnection *connection, const char *table_name, const FFI_ArrowSchema *schema_ptr, LanceDBRecordBatchReader *reader, LanceDBTable **table_out, char **error_message)
Create a new table with Arrow schema.
The caller is responsible for freeing the returned table with lancedb_table_free(). A non-NULL reader is taken only after the required pointers are non-NULL, the table name is valid UTF-8 and the Arrow schema imports. Failures before that point leave the reader caller-owned; after the schema imports, the reader is consumed even if table-name validation or table creation fails. Do NOT call lancedb_record_batch_reader_free() after the reader is consumed. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
table_name – - null-terminated C string containing the table name
schema_ptr – - pointer to Arrow C ABI schema
reader – - pointer to LanceDBRecordBatchReader or NULL for empty table
table_out – - pointer to receive the created table
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_create_with_options(const LanceDBConnection *connection, const char *table_name, const FFI_ArrowSchema *schema_ptr, LanceDBRecordBatchReader *reader, const LanceDBCreateTableOptions *options, LanceDBTable **table_out, char **error_message)
Create a new table with SDK create builder options.
This entry point applies the create mode, namespace path, custom location, per-table storage options, write options and external-blob option to the SDK create builder. Write options are applied before the per-table storage and external-blob setters so those setters extend rather than replace them. The SDK still applies its own precedence for the create mode and overlapping write parameters. The SDK decides which options a backend supports and may resolve a table location from the backend instead of using location.
For ExistOk, the SDK behavior is backend-dependent. A root listing compares the request schema (the reader schema when a reader is supplied, otherwise schema_ptr) and reopens through the callback with the supplied location and storage options. Nonempty namespaces and direct namespace connections open the existing table through the namespace backend without calling the C callback or comparing schemas. The remote client compares the schema only on its AlreadyExists reopen path.
On entry, a non-NULL table_out is set to NULL. It is written only on success, so a failure leaves it NULL. The caller is responsible for freeing the returned table with lancedb_table_free() and the Arrow schema with its own release callback. This function takes ownership of the reader (when not NULL) as soon as it is called. The reader is released exactly once, also when another argument, an option, the Arrow schema or the SDK rejects the create. Do NOT call lancedb_record_batch_reader_free() after calling this function. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
connection – - pointer to LanceDBConnection
table_name – - null-terminated C string containing the table name
schema_ptr – - pointer to Arrow C ABI schema, borrowed for the call
reader – - pointer to LanceDBRecordBatchReader or NULL for empty table
options – - pointer to LanceDBCreateTableOptions, or NULL for SDK defaults
table_out – - pointer to receive the created or existing table
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_arrow_schema(const LanceDBTable *table, FFI_ArrowSchema **schema_out, char **error_message)
Get table schema as Arrow C ABI.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
schema_out – - pointer to receive the Arrow schema
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure Caller is responsible for releasing the schema using Arrow C ABI
-
LanceDBError lancedb_table_schema_ipc_file(const LanceDBTable *table, LanceDBIpcBuffer *buffer_out, char **error_message)
Write the table schema as an Arrow IPC file that holds no batch.
On success, the buffer holds a readable Arrow IPC file with the full table schema and no record batch. Its schema can create a table of the same shape through lancedb_record_batch_reader_from_ipc_file() without any row. On entry, both outputs and the error message are cleared. The caller must free the bytes with lancedb_ipc_buffer_free(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable (borrowed, not consumed)
buffer_out – - pointer to receive the file bytes
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
unsigned long long lancedb_table_version(const LanceDBTable *table)
Get table version.
A version is never 0 for a valid table, so 0 is a safe failure sentinel. Use lancedb_table_version_with_status() when the failure details are needed.
- Parameters:
table – - pointer to LanceDBTable
- Returns:
Table version number on success, 0 on failure
-
LanceDBError lancedb_table_version_with_status(const LanceDBTable *table, uint64_t *version_out, char **error_message)
Get table version, preserving failures.
On success, version_out is set to the table version. On failure, version_out is left unchanged, so a caller can keep its own sentinel there. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
version_out – - pointer to receive the table version
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
unsigned long long lancedb_table_count_rows(const LanceDBTable *table)
Count rows in table.
Use lancedb_table_count_rows_with_status() when an empty table must be told apart from a failed call.
- Parameters:
table – - pointer to LanceDBTable
- Returns:
Number of rows in table on success, 0 on failure (or empty table)
-
LanceDBError lancedb_table_count_rows_with_status(const LanceDBTable *table, size_t *count_out, char **error_message)
Count rows in table, preserving failures.
On success, count_out is set to the number of rows, which is 0 for an empty table. On failure, count_out is left unchanged. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
count_out – - pointer to receive the row count
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_count_rows_filtered(const LanceDBTable *table, const char *filter, size_t *count_out, char **error_message)
Count rows in table matching an optional SQL filter, preserving failures.
On success, count_out is set to the number of matching rows, which is 0 when none match. On failure, count_out is left unchanged. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
filter – - optional SQL predicate; NULL counts every row. A non-NULL string, including an empty one, is passed to the SDK unchanged
count_out – - pointer to receive the matching row count
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_stats(const LanceDBTable *table, LanceDBTableStats *stats_out, char **error_message)
Get table statistics.
num_deleted_rows counts rows that were deleted but still occupy space on disk, since deletions are only marked in deletion files until the table is compacted (see lancedb_table_optimize()). A large value indicates that the table should be compacted. Fragments in which every row was deleted are dropped outright, so their rows are not counted. The value is -1 when the backend (e.g. a remote table) does not report deletion counts. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
stats_out – - pointer to receive the table statistics
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_add(const LanceDBTable *table, LanceDBRecordBatchReader *reader, char **error_message)
Add data to table using Arrow RecordBatchReader.
A non-NULL reader is consumed after the table and reader pointers are checked for NULL, so a NULL table or reader leaves the reader caller-owned. Do NOT call lancedb_record_batch_reader_free() after the reader is consumed. This entry point always appends and discards the SDK commit result; use lancedb_table_add_with_options() to choose a mode or read that version. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
reader – - pointer to LanceDBRecordBatchReader
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_add_with_options(const LanceDBTable *table, LanceDBRecordBatchReader *reader, const LanceDBAddOptions *options, LanceDBAddResult *result_out, char **error_message)
Add data to table with options and an optional SDK commit result.
A non-NULL reader is consumed before the table and options are validated, so every rejection after the NULL reader check frees it exactly once. A NULL reader returns without consuming anything. Do NOT call lancedb_record_batch_reader_free() after the reader is consumed.
When result_out is non-NULL, it is written only after a successful commit and is left unchanged on failure. The value is the SDK’s AddResult.version; zero is valid when a legacy remote server does not report a commit version. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
reader – - pointer to LanceDBRecordBatchReader; it is consumed on every path
options – - pointer to LanceDBAddOptions, or NULL for the SDK defaults
result_out – - optional pointer to receive the SDK commit version; NULL discards it
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_merge_insert(const LanceDBTable *table, LanceDBRecordBatchReader *data, const char *const *on_columns, size_t num_columns, const LanceDBMergeInsertConfig *config, char **error_message)
Merge insert data into table (upsert operation).
This function performs an upsert operation by joining on the specified columns. New records are inserted, existing records can be updated based on configuration. A non-NULL reader is consumed before the table, columns and config are validated, so it is freed even when those arguments are rejected. A NULL data pointer returns without consuming a reader. Do NOT call lancedb_record_batch_reader_free() after the reader is consumed. The expression in the config is not consumed and must still be freed by the caller with lancedb_expr_free(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
data – - pointer to LanceDBRecordBatchReader containing data to merge
on_columns – - array of column names to join on (typically key/id columns)
num_columns – - number of columns in the on_columns array
config – - pointer to LanceDBMergeInsertConfig for operation behavior (NULL for defaults)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_merge_insert_with_result(const LanceDBTable *table, LanceDBRecordBatchReader *data, const char *const *on_columns, size_t num_columns, const LanceDBMergeInsertOptions *options, LanceDBMergeInsertResult *result_out, char **error_message)
Merge insert with explicit actions and an SDK result.
This entry point performs one SDK merge. The reader supplies both the source schema and every source batch, so several batches are merged in a single operation. A reader over a schema-only Arrow IPC file is an empty source; combined with when_not_matched_by_source_delete, it can delete unmatched target rows.
The function takes ownership of the reader and frees it automatically on every path, including rejected arguments. Do NOT call lancedb_record_batch_reader_free() after calling this function. The options, their strings and on_columns are borrowed and remain owned by the caller.
On entry, *result_out and the error message are cleared. The result is only meaningful when the function returns LANCEDB_SUCCESS; on failure it stays zero. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
data – - pointer to LanceDBRecordBatchReader with the source schema and batches
on_columns – - array of column names to join on (typically key/id columns)
num_columns – - number of columns in the on_columns array (must be > 0)
options – - pointer to LanceDBMergeInsertOptions, or NULL for the default upsert
result_out – - pointer to receive the SDK commit version and counters
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_merge_insert_with_options(const LanceDBTable *table, LanceDBRecordBatchReader *data, const char *const *on_columns, size_t num_columns, const LanceDBMergeInsertOptions *options, const uint8_t *retries, const LanceDBExpr *when_not_matched_by_source_delete_expr, LanceDBMergeInsertResultV2 *result_out, char **error_message)
Merge insert with the complete option set and an optional result.
This entry point performs one SDK merge and reuses LanceDBMergeInsertOptions for its actions, SQL conditions, timeout and index choice. A NULL options pointer keeps the same default upsert as lancedb_table_merge_insert(): update every matched row and insert every unmatched source row.
The function takes ownership of the reader and frees it automatically on every path, including rejected arguments. Do NOT call lancedb_record_batch_reader_free() after calling this function. The options, their strings, retries and the expression are borrowed and remain owned by the caller; free the expression with lancedb_expr_free().
retries overrides the SDK’s remote transport retry budget for this call. A pointed-to 0 disables retries, while a NULL pointer keeps the SDK default. This budget is independent of local transaction-conflict retries, and the SDK never replays an ambiguous write result. Embedded tables ignore it.
The by-source-delete expression is evaluated against unmatched target rows and uses target column references directly, like the SQL filter in LanceDBMergeInsertOptions. When that action is enabled, the expression and a non-NULL SQL filter are mutually exclusive; setting both fails with LANCEDB_INVALID_ARGUMENT. A condition set for a disabled action is ignored.
On entry, a non-NULL *result_out and the error message are cleared. The result is only meaningful when the function returns LANCEDB_SUCCESS; on failure it stays zero. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
data – - pointer to LanceDBRecordBatchReader with the source schema and batches
on_columns – - array of column names to join on (typically key/id columns)
num_columns – - number of columns in the on_columns array (must be > 0)
options – - pointer to LanceDBMergeInsertOptions, or NULL for the default upsert
retries – - optional pointer to a uint8_t retry budget, or NULL for the SDK default
when_not_matched_by_source_delete_expr – - optional borrowed DataFusion expression, or NULL. Only used when the by-source-delete action is enabled
result_out – - optional pointer to receive the complete SDK result
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_update(const LanceDBTable *table, const char *const *columns, const char *const *expressions, size_t num_assignments, const char *predicate, LanceDBUpdateResult *result_out, char **error_message)
Update rows in a table using SQL expressions.
Each entry in columns is paired with the entry at the same index in expressions. The input order is preserved when passing the assignments to the SDK, but it is not an evaluation order: every expression sees the row as it was before the update. For example, updating a from b and b from a swaps their original values. Assignments are applied in a single commit. The caller is responsible for quoting string literals in expressions (for example “‘updated’”).
The arrays and their strings are borrowed for the duration of the call. They are not consumed and remain owned by the caller. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
columns – - array of column names to update
expressions – - array of SQL expressions, one per column
num_assignments – - number of entries in columns and expressions (must be > 0)
predicate – - SQL predicate selecting the rows to update; NULL or an empty string updates every row
result_out – - pointer to receive the affected rows and committed version; legacy remote empty responses can report zero (unknown)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_update_with_options(const LanceDBTable *table, const char *const *columns, const char *const *expressions, size_t num_assignments, const char *predicate, const LanceDBUpdateOptions *options, LanceDBUpdateResult *result_out, char **error_message)
Update rows in a table using SQL expressions, with options and an optional result.
Assignments are paired and evaluated exactly like lancedb_table_update(). The options are borrowed for the call and are not consumed. A NULL options pointer uses the SDK defaults. result_out may be NULL when the caller does not need the affected rows or commit version; when non-NULL, it is written only after a successful commit and is left unchanged on failure.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
columns – - array of column names to update
expressions – - array of SQL expressions, one per column
num_assignments – - number of entries in columns and expressions (must be > 0)
predicate – - SQL predicate selecting the rows to update; NULL or an empty string updates every row
options – - pointer to LanceDBUpdateOptions, or NULL for the SDK defaults
result_out – - optional pointer to receive the affected rows and committed version; NULL discards the result
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_delete(const LanceDBTable *table, const char *predicate, char **error_message)
Delete rows from table based on predicate.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
predicate – - null-terminated C string containing SQL WHERE clause
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_delete_with_result(const LanceDBTable *table, const char *predicate, LanceDBDeleteResult *result_out, char **error_message)
Delete rows from table based on predicate, with an optional SDK result.
The predicate and error reporting follow lancedb_table_delete(). When result_out is non-NULL it receives the number of deleted rows and the commit version after a successful delete; it is left unchanged on failure. NULL discards the result.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
predicate – - null-terminated C string containing SQL WHERE clause
result_out – - optional pointer to receive the deleted rows and committed version
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_df_delete(const LanceDBTable *table, LanceDBExpr *expr, char **error_message)
Delete rows from table using a DataFusion expression.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
expr – - pointer to LanceDBExpr (consumed by this function; do not use or free after calling)
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_df_delete_with_result(const LanceDBTable *table, LanceDBExpr *expr, LanceDBDeleteResult *result_out, char **error_message)
Delete rows from table using a DataFusion expression, with an optional SDK result.
The expression is consumed on every path, exactly like lancedb_table_df_delete(). When result_out is non-NULL it receives the number of deleted rows and the commit version after a successful delete; it is left unchanged on failure. NULL discards the result.
If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
expr – - pointer to LanceDBExpr (consumed by this function; do not use or free after calling)
result_out – - optional pointer to receive the deleted rows and committed version
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_add_columns(const LanceDBTable *table, const char *const *names, const char *const *expressions, size_t num_columns, uint64_t *version_out, char **error_message)
Add new columns using SQL expressions.
The arrays and their strings are borrowed for the duration of the call. They are not consumed and remain owned by the caller. Names and expressions must be non-empty. On success, version_out is the operation’s own commit version; it may be 0 for legacy remote servers that do not report a version. On failure, version_out is left unchanged. No separate table version lookup is performed. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
names – - array of new column names
expressions – - array of SQL expressions, one per new column
num_columns – - number of entries in names and expressions (must be > 0)
version_out – - pointer to receive the commit version returned by the SDK
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_add_columns_all_nulls(const LanceDBTable *table, const FFI_ArrowSchema *schema, uint64_t *version_out, char **error_message)
Add typed columns whose existing rows read as NULL.
This binds NewColumnTransform::AllNulls: every field of
schemais added as a new column and every existing row reads NULL for it. Each field must be nullable, as the SDK requires, and its data type is added unchanged. Field names, types, and field metadata are taken from the Arrow schema. The schema is only read for the duration of the call and remains owned by the caller; it is not consumed. On success, version_out is the operation’s own commit version; it may be 0 for legacy remote servers that do not report a version. On failure, version_out is left unchanged. No separate table version lookup is performed. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().- Parameters:
table – - pointer to LanceDBTable
schema – - pointer to a borrowed Arrow C ABI schema with at least one field
version_out – - pointer to receive the commit version returned by the SDK
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_alter_columns(const LanceDBTable *table, const LanceDBColumnAlteration *alterations, size_t num_alterations, uint64_t *version_out, char **error_message)
Alter column names and nullability.
Each entry must set a non-empty path and change at least the name or the nullability. Rename and nullability are independent: a NULL rename keeps the current name, and set_nullable=0 keeps the current nullability. The array and its strings are borrowed for the duration of the call. On success, version_out is the operation’s own commit version; it may be 0 for legacy remote servers that do not report a version. On failure, version_out is left unchanged. No separate table version lookup is performed. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
alterations – - array of column alterations
num_alterations – - number of entries in alterations (must be > 0)
version_out – - pointer to receive the commit version returned by the SDK
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_alter_columns_with_cast(const LanceDBTable *table, const LanceDBColumnAlterationWithCast *alterations, size_t num_alterations, uint64_t *version_out, char **error_message)
Alter column names, nullability, and data types.
This is the same operation as lancedb_table_alter_columns, with an optional cast_to data type per entry. Each entry must set a non-empty path and change at least the name, the nullability, or the data type. Rename, nullability, and cast are independent and can be combined in one commit. A non-NULL cast_to must point to an Arrow C ABI schema with exactly one field; only its data type is used, and the schema remains owned by the caller. A NULL cast_to leaves the type unchanged. The array, its strings, and its cast schemas are borrowed for the duration of the call. On success, version_out is the operation’s own commit version; it may be 0 for legacy remote servers that do not report a version. On failure, version_out is left unchanged. No separate table version lookup is performed.
The pinned embedded Lance backend rejects changing a currently nullable field to NOT NULL in the same call as a cast, even when the field has no NULL values. The SDK error is returned unchanged; apply the cast and the nullability change in separate calls. Renaming a field, or relaxing a NOT NULL field to NULL, can be combined with a cast. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
alterations – - array of column alterations that may cast
num_alterations – - number of entries in alterations (must be > 0)
version_out – - pointer to receive the commit version returned by the SDK
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_drop_columns(const LanceDBTable *table, const char *const *columns, size_t num_columns, uint64_t *version_out, char **error_message)
Drop columns from a table.
Names must be non-empty. The array and its strings are borrowed for the duration of the call. On success, version_out is the operation’s own commit version; it may be 0 for legacy remote servers that do not report a version. On failure, version_out is left unchanged. No separate table version lookup is performed. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
columns – - array of column names to drop
num_columns – - number of entries in columns (must be > 0)
version_out – - pointer to receive the commit version returned by the SDK
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
LanceDBError lancedb_table_update_field_metadata(const LanceDBTable *table, const LanceDBFieldMetadataUpdate *updates, size_t num_updates, uint64_t *version_out, char **error_message)
Update per-field metadata through the SDK.
This binds lancedb::table::Table::update_field_metadata and works on embedded and remote tables. Each update is merged into its field’s existing metadata unless replace is set, in which case it swaps the field’s whole metadata map. The array, its entries, and their strings are borrowed for the duration of the call. On success, version_out is the operation’s own commit version; it may be 0 for legacy remote servers that do not report a version. On failure, version_out is left unchanged. No separate table version lookup is performed. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().
- Parameters:
table – - pointer to LanceDBTable
updates – - array of field metadata updates
num_updates – - number of entries in updates (must be > 0)
version_out – - pointer to receive the commit version returned by the SDK
error_message – - optional pointer to receive detailed error message (NULL to ignore)
- Returns:
Error code indicating success or failure
-
struct LanceDBWriteOptions
- #include <lancedb.h>
Per-call Lance write parameters shared by table create and add.
set_fields selects the fields that are read; every other field keeps the SDK default. A NULL pointer to this struct, or set_fields equal to zero, keeps the SDK WriteOptions without Lance write parameters. That is what default remote table creation requires.
data_storage_version is parsed by the SDK’s own version parser, for example “2.0”, “2.1”, “legacy” or “stable”. It must not be NULL when its bit is set. enable_stable_row_ids must be 0 or 1 when its bit is set. The string is borrowed for the duration of the call.
-
struct LanceDBCreateTableOptions
- #include <lancedb.h>
Options for lancedb_table_create_with_options().
mode is one of the LanceDBCreateTableMode values. namespace_path is an array of namespace_path_len borrowed strings; NULL with length 0 means the root namespace. A positive length with a NULL array, a NULL part or a part that is not valid UTF-8 is rejected with LANCEDB_INVALID_ARGUMENT. location is an optional borrowed custom table location; NULL derives it from the database URI and the table name. On a root listing database it is also the location used by the ExistOk callback when reopening the existing table. Namespace and remote backends resolve table locations themselves and may reject or ignore it according to the SDK.
storage_keys and storage_values are parallel arrays of storage_count borrowed strings for this table only. An empty array leaves the SDK’s per-table storage options unset. The same options are passed to the SDK ExistOk callback when a root listing table is reopened. write_options is NULL for the SDK defaults or points to a readable LanceDBWriteOptions. allow_external_blob_outside_bases must be 0 or 1. The SDK decides which options a backend supports and applies its own precedence to overlapping create/open options and write parameters.
-
struct LanceDBFragmentSummaryStats
- #include <lancedb.h>
Statistics on the number of rows in table fragments.
-
struct LanceDBFragmentStats
- #include <lancedb.h>
Statistics on table fragments.
-
struct LanceDBTableStats
- #include <lancedb.h>
Table statistics structure.
-
struct LanceDBAddOptions
- #include <lancedb.h>
Options for lancedb_table_add_with_options().
A zero-initialized struct (all fields zero and pointers NULL) uses the default append mode, the default Error NaN handling, no Lance write parameters, no retry or write-parallelism override, and the external-blob switch disabled. A NULL options pointer is equivalent to that struct. set_fields only controls retries and write_parallelism; mode, on_nan_vectors, write_options and allow_external_blob_outside_bases are read from every non-NULL struct.
mode is one of the LanceDBAddDataMode values. The binding applies that one mode to both the SDK add builder and any supplied Lance write parameters, because the embedded SDK otherwise uses the write parameters’ own mode. This keeps a caller that also requests a layout override on the intended append/overwrite path.
write_options is NULL for the SDK defaults or points to a readable LanceDBWriteOptions. The SDK decides which options a backend supports. Remote add rejects non-default layout sizes; its insert request carries only the mode, so data storage version and stable-row-ID overrides have no effect there. allow_external_blob_outside_bases is embedded only and must be 0 or 1; a remote add with it set to 1 returns LANCEDB_NOT_SUPPORTED.
retries is a remote per-call failed-attempt threshold and is only read when its bit is set. A value of 0 disables retries explicitly, while an unset bit keeps the SDK default. Embedded tables ignore it, and ambiguous write results are never replayed.
on_nan_vectors is one of the LanceDBNaNVectorBehavior values; zero selects the SDK default Error behavior.
write_parallelism is the number of parallel write streams and is only read when its bit is set. An unset bit lets the SDK estimate it. Enterprise servers older than 0.4.0 always use the single-request add path, and empty input takes that path even on multipart-capable servers. An explicit zero is rejected by the SDK’s input validation before backend dispatch and returns LANCEDB_INVALID_INPUT.
The struct and its write_options are borrowed for the duration of the call.
-
struct LanceDBAddResult
- #include <lancedb.h>
Result of an add operation.
version is copied unchanged from the SDK’s AddResult; this layer does not recompute or synthesize it. A value of zero means a legacy remote server did not return a commit version.
-
struct LanceDBMergeInsertResult
- #include <lancedb.h>
Result of a merge insert operation.
Every field is copied unchanged from the SDK’s MergeResult; this layer does not fill in or synthesize a value. The SDK defaults each field missing from a remote response to zero, so zero means “not reported” rather than necessarily no work. num_attempts is the merge attempt count reported by the SDK or server, not the number of HTTP requests. A legacy remote empty response, or a merge through the RTE write path, can succeed with all five fields zero. A version of 0 likewise means the backend did not report a commit version, not necessarily that no commit happened.
-
struct LanceDBMergeInsertResultV2
- #include <lancedb.h>
Result of lancedb_table_merge_insert_with_options.
This is the SDK’s complete MergeResult, copied unchanged. It is a separate struct so LanceDBMergeInsertResult keeps its published layout. The SDK defaults each field missing from a remote response to zero, so zero means “not reported” rather than necessarily no work. num_attempts is the merge attempt count reported by the SDK or server, not the number of HTTP requests. num_rows is the SDK’s total written-row count: on the standard path it equals num_inserted_rows + num_updated_rows, while the RTE write path can report only num_rows and leave the breakdown zero. A legacy remote empty response can succeed with every field zero, and a version of 0 means the backend did not report a commit version.
-
struct LanceDBUpdateOptions
- #include <lancedb.h>
Options for lancedb_table_update_with_options.
set_fields selects the fields that are read; every other field keeps the SDK default. An unknown set_fields bit is rejected with LANCEDB_INVALID_ARGUMENT before the update starts.
retries is a failed-attempt threshold, not a replay count. For a sequence of retryable HTTP status responses, the SDK increments its request-failure counter before testing it against the budget: with repeated 409 responses, 1 returns the first failure without resending, while 3 can resend twice and returns the third failure. Embedded tables ignore it. Leave the LANCEDB_UPDATE_RETRIES bit unset to keep the SDK default; set it with 0 to disable retries explicitly. Ambiguous write results are never replayed.
The options struct is borrowed for the duration of the call and is not consumed.
-
struct LanceDBUpdateResult
- #include <lancedb.h>
Result of an update operation.
Embedded tables report the actual affected rows and commit version. A legacy remote server that returns an empty update response can report zero for either field, which means unknown there rather than a literal zero.
-
struct LanceDBDeleteResult
- #include <lancedb.h>
Result of a delete operation.
Every field is copied unchanged from the SDK’s DeleteResult; this layer does not fill in or synthesize a value. The SDK defaults each field missing from a remote response to zero independently: a version-only response leaves num_deleted_rows at zero, and a count-only response leaves version at zero. Zero can mean “not reported”; a reported num_deleted_rows of zero is also valid when no rows matched. An empty legacy response leaves both fields zero.
-
struct LanceDBColumnAlteration
- #include <lancedb.h>
One column alteration for lancedb_table_alter_columns.
pathnames the existing column.rename, when non-NULL, sets the new column name.set_nullabledistinguishes “leave nullability unchanged” (0) from applyingnullable(1), so an explicit nullable=false request is not mistaken for an omitted one.nullableis 0 for NOT NULL and non-zero for NULL.
-
struct LanceDBColumnAlterationWithCast
- #include <lancedb.h>
One column alteration for lancedb_table_alter_columns_with_cast.
The first four fields have the same meaning as LanceDBColumnAlteration.
cast_to, when non-NULL, points to a borrowed Arrow C ABI schema that holds exactly one field. Only that field’s data type is used; its name, nullability and metadata are ignored. The caller keeps ownership of the schema and must still release it with the Arrow C ABI release callback.
-
struct LanceDBFieldMetadataEntry
- #include <lancedb.h>
One field metadata key change for lancedb_table_update_field_metadata.
keymust be a non-empty string. A non-NULLvaluesets the key to that value; a NULL value removes the key. Keys must be unique within one update. The strings are borrowed for the duration of the call.
-
struct LanceDBFieldMetadataUpdate
- #include <lancedb.h>
One field metadata update for lancedb_table_update_field_metadata.
pathaddresses the field by its dot-separated path, for exampleziporaddress.zip.entriesholdsnum_entrieskey changes applied in order and must be non-NULL when num_entries is greater than zero. Whenreplaceis 0, the entries merge into the field’s existing metadata; a merge with zero entries is rejected because it changes nothing. Whenreplaceis non-zero, the entries replace the field’s entire metadata map, so a replace with zero entries clears the metadata.
-
enum LanceDBCreateTableMode