Skip to content

feat: support shared session for fragment API - #8034

Merged
Xuanwo merged 3 commits into
lance-format:mainfrom
zhangyue19921010:fragment-session-cache-new
Aug 11, 2026
Merged

feat: support shared session for fragment API#8034
Xuanwo merged 3 commits into
lance-format:mainfrom
zhangyue19921010:fragment-session-cache-new

Conversation

@zhangyue19921010

Copy link
Copy Markdown
Contributor

Closes: #7974

@github-actions github-actions Bot added A-python Python bindings A-java Java bindings + JNI enhancement New feature or request labels Jul 28, 2026
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…che-new

# Conflicts:
#	python/python/tests/test_session.py

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gate recommendation: approve.

The change fixes append schema inference at the correct boundary: schema lookup and fragment writing now share the complete session, object-store parameters, commit handler, and durable field IDs. Exposing that same session through Python and Java preserves existing no-session behavior while enabling cache reuse.

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gate recommendation: approve.

The change fixes append schema inference at the correct boundary: schema lookup and fragment writing share the complete session, object-store parameters, commit handler, and durable field IDs. Exposing the same session through Python and Java preserves existing no-session behavior while enabling cache reuse.

}

async fn existing_dataset(&self, params: &WriteParams) -> Result<Option<Dataset>> {
match self.load_existing_dataset(params).await {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why we need this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When no schema is given, FragmentCreateBuilder::write loads the existing dataset to infer the schema (with correct field ids). Previously this load built a bare DatasetBuilder that ignored WriteParams.session, so it always bypassed the shared session's metadata cache. Now it goes through load_existing_dataset, which passes the session (plus store params / commit handler) into ReadParams, so the manifest load hits the shared cache.

Ok(None)
}
let params = self.write_params.map(Cow::Borrowed).unwrap_or_default();
match self.load_existing_dataset(&params).await {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

feels like we just repeat the logic here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The shared loading logic is already extracted into load_existing_dataset; only the error handling is kept separate on purpose, because the two callers tolerate different errors:

  • existing_dataset_schema only swallows DatasetNotFound
  • existing_dataset swallows both DatasetNotFound and NotFound

Merging them would change behavior — e.g. schema inference would silently fall back to the reader schema on a missing manifest file (NotFound) instead of surfacing the error. To keep this PR behavior-compatible, I kept the match arms as they were before.

@Xuanwo Xuanwo added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 10, 2026
@Xuanwo
Xuanwo merged commit 978cd25 into lance-format:main Aug 11, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-java Java bindings + JNI A-python Python bindings enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support fragment session cache

2 participants