Skip to content

feat(python): expose DatasetDeltaBuilder and relevant apis#5091

Merged
jackye1995 merged 8 commits intolance-format:mainfrom
yanghua:feat-py-delta
Nov 27, 2025
Merged

feat(python): expose DatasetDeltaBuilder and relevant apis#5091
jackye1995 merged 8 commits intolance-format:mainfrom
yanghua:feat-py-delta

Conversation

@yanghua
Copy link
Copy Markdown
Collaborator

@yanghua yanghua commented Oct 29, 2025

No description provided.

@github-actions github-actions Bot added enhancement New feature or request python labels Oct 29, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yanghua yanghua marked this pull request as ready for review October 29, 2025 13:08
@yanghua yanghua requested a review from jackye1995 October 29, 2025 14:40
Comment thread python/python/lance/dataset.py Outdated
"""
return SqlQueryBuilder(self._ds.sql(sql))

def delta(self) -> "DatasetDeltaBuilder":
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.

I think python don't really have builders, what about we just have all the builder inputs as function arguments?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

After thinking about this suggestion. There are two opinions:

  • There are some config options that have some check logic in build fn:

pub fn build(self) -> Result<DatasetDelta> {

Reusing the DatasetDeltaBuilder so that we can reuse the check logic?

  • The build pattern could keep the scalarity for the future.

WDYT?

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.

what about having the inputs in the function, so it's functional style, and then we internally call into the binded builder within the function? So the DatasetDeltaBuilder is just internal usage and can be _DatasetDeltaBuilder

builder = builder.with_begin_version(begin_version)
builder = builder.with_end_version(end_version)

return builder.build()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agree DatasetDeltaBuilder could be _DatasetDeltaBuilder. Can we reuse the arg check in the builder.build() function?

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.

What do you mean? It should already use it?

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.

oh I see what you mean, you mean we don't need to duplicate the checks, agree

Comment thread python/python/lance/dataset.py Outdated
Comment on lines +3656 to +3675
has_compared_against = compared_against is not None
has_range = begin_version is not None or end_version is not None

if has_compared_against and has_range:
raise ValueError(
"Cannot specify both 'compared_against' and "
"'begin_version'/'end_version'. Use one or the other."
)

if not has_compared_against and not has_range:
raise ValueError(
"Must specify either 'compared_against' or both "
"'begin_version' and 'end_version'."
)

if has_range:
if begin_version is None or end_version is None:
raise ValueError(
"Both 'begin_version' and 'end_version' must be specified together."
)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I mean, this block is not necessary, because it has been checked in Rust:

(None, Some(begin), Some(end)) => (begin, end),

And it could be reused for Python and Java?

@jackye1995 jackye1995 merged commit f0094ed into lance-format:main Nov 27, 2025
25 of 26 checks passed
jackye1995 added a commit to jackye1995/lance that referenced this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants