LeonSGP 57a6cce681 fix(python): omit excluded model fields from persistence (#4465)
LanceDB serializes Pydantic rows with `model_dump()`, which omits
`Field(exclude=True)`, but currently constructs an Arrow schema
containing those same fields. Creating a local table therefore fails
when an excluded field is non-nullable, including defaulted transient
fields and nested models.

Filter unconditionally excluded fields when converting model schemas,
including nested structs. Skip excluded source/vector fields when
deriving embedding configuration so persistent metadata does not refer
to absent columns. Keep `field_names()` as model-field reflection.

Tests exercise implicit and explicit schemas, synchronous and
asynchronous create/add/reopen/readback, nested fields, defaults and
default factories, retained fields, and local deterministic embeddings.
Excluded values are not persisted; `to_pydantic` restores declared
defaults. Conditional exclusion and readback of required excluded fields
without defaults are outside this change.

Implemented with assistance from gpt-6.1-sol; final diff reviewed
locally.

Local validation reuses the native extension matching official base
d864e7198f. The current-main Pydantic
module is byte-identical to that base, but current-main native code has
not been rebuilt. Slow/S3 tests, remote services, and other operating
systems were not validated.

Reproducible commands after preparing the documented development
environment (relative `.venv` examples are equivalent commands; actual
local runs use absolute read-only environments and fresh task-private
working directories):

```sh
PYTHONPATH=python/python .venv/bin/python -m pytest python/python/tests/test_pydantic_excluded_fields.py -q -p no:cacheprovider
PYTHONPATH=python/python .venv/bin/python -m pytest python/python/tests -m 'not slow and not s3_test' -q -rs -p no:cacheprovider
PYTHONPATH=python/python .venv/bin/python -m pytest --doctest-modules python/python/lancedb -q --tb=short
(cd python && PYTHONPATH=python ../.venv/bin/pyright --pythonpath ../.venv/bin/python)
.venv/bin/ruff check .
.venv/bin/ruff format --check .
.venv/bin/python -m pre_commit run --files python/python/lancedb/pydantic.py python/python/tests/test_pydantic_excluded_fields.py
git diff --check d864e7198f HEAD
```

Final frozen-source results:
- EXCLUDE_TARGET_COMPLETE_ORIGINAL_RED: Python 3.11.14, exit 1,
1.900076000019908 seconds, {"failed"=>7}.
- EXCLUDE_TARGET_EMBEDDING: Python 3.11.14, exit 0, 1.3686820000002626
seconds, {"passed"=>7}.
- EXCLUDE_TARGET313: Python 3.13.11, exit 0, 1.7214069999754429 seconds,
{"passed"=>7}.
- EXCLUDE_FULL311: Python 3.11.14, exit 0, 217.56785399999353 seconds,
{"passed"=>1531, "skipped"=>36, "deselected"=>68, "warnings"=>251}.
- EXCLUDE_FULL313: Python 3.13.11, exit 0, 197.93847399999504 seconds,
{"passed"=>1528, "skipped"=>37, "deselected"=>68, "warnings"=>251}.
- EXCLUDE_DOCTEST313: Python 3.13.11, exit 0, 11.8951390000002 seconds,
{"passed"=>71, "skipped"=>6, "warnings"=>2}.
- EXCLUDE_PYRIGHT: Python 3.13.11, exit 0, 5.808195000019623 seconds,
{"warnings"=>0, "errors"=>0}.
- EXCLUDE_PRECOMMIT: Python 3.11.14, exit 0, 0.5624079999979585 seconds,
{"passed"=>4, "skipped"=>2}.
- EXCLUDE_RUFF_FINAL: Ruff 0.9.9, exit 0, 0.06722099997568876 seconds,
{}.
- EXCLUDE_FORMAT_FINAL: Ruff 0.9.9, exit 0, 0.033322000002954155
seconds, {"files_formatted"=>157}.
- EXCLUDE_SYNTAX: Python 3.11.14, exit 0, 0.031629999983124435 seconds,
{"files_compiled"=>2}.
- EXCLUDE_DIFF_CHECK: Git, exit 0, 0.024460999993607402 seconds, {}.
2026-10-23 02:46:34 +08:00
2023-03-17 18:15:19 -07:00
2025-03-10 09:01:23 -07:00

Reverie LanceDB Website Blog Discord Twitter LinkedIn

LanceDB

The Multimodal Lakehouse for AI

How to Install ✦ Detailed Documentation ✦ Tutorials and Recipes ✦ Contributors

The ultimate multimodal data platform for AI/ML applications.

LanceDB is designed for fast, scalable, and production-ready vector search. It is built on top of the Lance columnar format. You can store, index, and search over petabytes of multimodal data and vectors with ease. LanceDB is a central location where developers can build, train and analyze their AI workloads.


Demo: Multimodal Search by Keyword, Vector or with SQL

LanceDB Multimodal Search

Star LanceDB to get updates!

⭐ Click here ⭐ to see how fast we're growing!

Key Features:

  • Fast Vector Search: Search billions of vectors in milliseconds with state-of-the-art indexing.
  • Comprehensive Search: Support for vector similarity search, full-text search and SQL.
  • Multimodal Support: Store, query and filter vectors, metadata and multimodal data (text, images, videos, point clouds, and more).
  • Advanced Features: Zero-copy, automatic versioning, manage versions of your data without needing extra infrastructure. GPU support in building vector index.

Products:

  • Open Source & Local: 100% open source, runs locally or in your cloud. No vendor lock-in.
  • Cloud and Enterprise: Production-scale vector search with no servers to manage. Complete data sovereignty and security.

Ecosystem:

  • Columnar Storage: Built on the Lance columnar format for efficient storage and analytics.
  • Seamless Integration: Python, Node.js, Rust, and REST APIs for easy integration. Native Python and Javascript/Typescript support.
  • Rich Ecosystem: Integrations with LangChain 🦜️🔗, LlamaIndex 🦙, Apache-Arrow, Pandas, Polars, DuckDB and more on the way.

How to Install:

Follow the Quickstart doc to set up LanceDB locally.

API & SDK: We also support Python, Typescript and Rust SDKs

Interface Documentation
Python SDK https://lancedb.github.io/lancedb/python/python/
Typescript SDK https://lancedb.github.io/lancedb/js/globals/
Rust SDK https://docs.rs/lancedb/latest/lancedb/index.html
REST API https://docs.lancedb.com/api-reference/rest

Join Us and Contribute

We welcome contributions from everyone! Whether you're a developer, researcher, or just someone who wants to help out.

If you have any suggestions or feature requests, please feel free to open an issue on GitHub or discuss it on our Discord server.

Check out the GitHub Issues if you would like to work on the features that are planned for the future. If you have any suggestions or feature requests, please feel free to open an issue on GitHub.

Contributors

Stay in Touch With Us


Website Blog Discord Twitter LinkedIn

S
Description
Developer-friendly OSS embedded retrieval library for multimodal AI. Search More; Manage Less.
Readme Apache-2.0
108 MiB
Languages
Rust 42.6%
Python 27.1%
HTML 21.4%
TypeScript 7.9%
Java 0.7%
Other 0.2%