Skip to content

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented Nov 17, 2025

Rationale for this change

This is a big one, and was on my mind for a long time, but I think we should clean this up before a 1.x release.

I bumped into this once more when I tried to extend from the IcebergBaseModel, but that did not work well with the Generic.

From the beginning we had these Generic in the expressions system, but it really never worked as we hoped. It came from Java where Generics are much stronger, but the static typing of Python/mypy doesn't really follow the types.

Are these changes tested?

Are there any user-facing changes?

From the beginning we had these Generic in the expressions
system, but it really never worked as we hoped. It came from
Java where Generics are much stronger, but the static typing
of Python/mypy doesn't really follow the types.
Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

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

LGTM! mypy is happy too

@kevinjqliu kevinjqliu merged commit 4cd1a63 into apache:main Nov 18, 2025
8 checks passed
Copy link
Collaborator

@sungwy sungwy left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @Fokko !

I think @kevinjqliu beat me to the punch while I was reviewing it, but I left some comments. 😄


@abstractmethod
def visit_equal(self, term: BoundTerm[L], literal: Literal[L]) -> T:
def visit_equal(self, term: BoundTerm, literal: Literal[L]) -> T:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, but do you think it would make sense to align with your change in expressions/__init__.py and use LiteralValue here?

Suggested change
def visit_equal(self, term: BoundTerm, literal: Literal[L]) -> T:
def visit_equal(self, term: BoundTerm, literal: LiteralValue) -> T:

Comment on lines +39 to +42
if TYPE_CHECKING:
LiteralValue = Literal[Any]
else:
LiteralValue = Literal
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are your thoughts on moving this to pyiceberg.typedef instead? I think that'll allow it to be reused by other modules for static type checking.

Copy link
Contributor

Choose a reason for hiding this comment

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

good one! sorry i merged it before you got a chance to submit your reviews
Looks like Fokko has followed up with #2769 :)

@Fokko Fokko deleted the fd-remove-generic branch November 18, 2025 10:31
Fokko added a commit that referenced this pull request Nov 19, 2025
# Rationale for this change

Follow up on #2750

## Are these changes tested?

## Are there any user-facing changes?

<!-- In the case of user-facing changes, please add the changelog label.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants