Skip to content

feat(python,rust): allow lancedb.blob() to set blob tier thresholds - #4323

Merged
geruh merged 3 commits into
lancedb:mainfrom
SIDDARTHAREDDY8:oss-bhai-2026-09-24-lancedb-blob-thresholds
Oct 13, 2026
Merged

geruh merged 3 commits into
lancedb:mainfrom
SIDDARTHAREDDY8:oss-bhai-2026-09-24-lancedb-blob-thresholds

Conversation

@SIDDARTHAREDDY8

Copy link
Copy Markdown
Contributor

Closes #4285.

What changed

Python (python/python/lancedb/schema.py): lancedb.blob() now accepts optional inline_size_threshold, dedicated_size_threshold, and pack_file_size_threshold keyword arguments, forwarded to lance.blob_field (which validates them and stores them as lance-encoding:blob-*-threshold field metadata). When all thresholds are omitted the behavior is unchanged, including the no-pylance fallback type. Setting a threshold without pylance installed raises a clear error instead of silently writing unvalidated metadata.

Rust (rust/lancedb/src/blob.rs): added blob_with_options(name, nullable, options) plus BlobOptions (a re-export of lance::blob::BlobFieldOptions, so thresholds are built exactly the way lance builds them). With BlobOptions::default() the result is identical to blob(). Note: lance's Rust API at the pinned version (v13.0.0-beta.12) exposes only the inline and dedicated size thresholds, so there is no pack-file-size-threshold option on the Rust side yet.

Tests

  • New pytest tests in python/python/tests/test_blob.py: thresholds land in field metadata, defaults carry no threshold metadata, invalid values raise ValueError/TypeError.
  • Verified the Python logic standalone against pylance 12.0.0 (metadata keys/values, validation rules, no-pylance fallback and error paths). The full pytest suite needs the compiled native extension, which is not built in this environment.
  • New Rust unit tests and a doctest in rust/lancedb/src/blob.rs (metadata assertions, default-options equivalence). Not compiled locally (no Rust toolchain in this environment); please rely on CI for the Rust build.

Note: this PR was drafted with AI assistance; I reviewed and tested the changes.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added enhancement New feature or request Python Python SDK Rust Rust related issues labels Sep 25, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 25, 2026
@SIDDARTHAREDDY8

Copy link
Copy Markdown
Contributor Author

Friendly ping — would appreciate a review when possible.

@lancedb-gatekeeper lancedb-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Oct 6, 2026
@SIDDARTHAREDDY8

Copy link
Copy Markdown
Contributor Author

Pushed 9771a10: ran rustfmt on the blob_with_options signature in rust/lancedb/src/blob.rs (single line, as the Format Rust check requested). No logic change. The remaining rerun failures look unrelated to this PR: the cargo-deny job failed to install its pinned toolchain, and the Node 24 test failure was a single S3/DynamoDB integration test timing out (907 of 909 tests passed).

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 12, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 12, 2026

@geruh geruh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @SIDDARTHAREDDY8! Did a pass

inline_size_threshold: Optional[int] = None,
dedicated_size_threshold: Optional[int] = None,
pack_file_size_threshold: Optional[int] = None,
) -> pa.Field:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I need to try this, but should we put * before the three threshold arguments to make keyword only? seems like blob("payload", True, 8192) binds 8192 to inline_size_threshold.

Comment thread python/python/lancedb/schema.py Outdated
blob_type = _resolve_blob_type()
return pa.field(name, blob_type(), nullable=nullable)
try:
from lance import blob_field

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this file already imports importlib for the optional lance dependency. wdyt about using that for the import like importlib.import_module("lance") or pssing in directly lance.blob_field like the others.

Comment thread python/python/lancedb/schema.py Outdated
raise ValueError(
"Setting blob tier thresholds requires pylance to be installed"
) from err
return blob_field(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the _resolve_blob_type() check here? This path skips the existing check for conflicting extension registrations.

Comment thread rust/lancedb/src/blob.rs
/// [`lance::blob::blob_field_with_options`] builds them. Note that lance does
/// not currently expose a pack file size threshold option, so only the inline
/// and dedicated size thresholds are supported here.
pub use lance::blob::BlobFieldOptions as BlobOptions;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python supports all three thresholds, but Rust only exposes two. Should we keep our own BlobOptions and store the pack threshold in field metadata?

…keep registration check

Signed-off-by: SIDDARTHA REDDY <[email protected]>
@SIDDARTHAREDDY8

Copy link
Copy Markdown
Contributor Author

Thanks for the pass. Pushed f461aba addressing the three Python points: the three thresholds are now keyword-only (so blob("payload", True, 8192) no longer binds positionally), the threshold path now loads lance via importlib.import_module("lance") like the rest of the file, and it calls _resolve_blob_type() before delegating to lance.blob_field so the conflicting-registration check is no longer skipped. The check runs after the import, so the missing-pylance path still raises before any fallback registration. Local verification is py_compile only (no pyarrow on my box); CI will run the blob tests.

On the Rust point: lance BlobFieldOptions has no pack threshold field, so keeping our own BlobOptions and storing the pack threshold in field metadata would mean defining that metadata format on our side. Happy to do that if that is the direction you want; otherwise I can leave Rust at the two thresholds lance supports and say so in the doc comment. Which do you prefer?

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 12, 2026

@lancedb-gatekeeper lancedb-gatekeeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The author's update is verified: thresholds are keyword-only, the optional import uses importlib, and threshold calls now reject competing Arrow registrations. Metadata and validation still delegate to Lance; focused tests cover these paths, unchanged defaults, and missing-pylance behavior. This preserves the field-builder solution to #4285, with the prior create/write/read evidence still applicable.

For Rust, keep the upstream options alias and its already documented two-threshold scope. Lance already defines the pack-file metadata key; extending Lance's builder is a simpler future path to parity than maintaining a separate options type here.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 12, 2026

@geruh geruh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thnx @SIDDARTHAREDDY8!

@geruh
geruh merged commit 38a62db into lancedb:main Oct 13, 2026
39 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance. Python Python SDK Rust Rust related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(python): let lancedb.blob() set blob tier thresholds

2 participants