Add CAST expression support to parser#3207
Open
nssalian wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
@Fokko @geruh @kevinjqliu PTAL |
Fokko
reviewed
May 7, 2026
Fokko
reviewed
May 7, 2026
Comment on lines
+285
to
+288
| expected = EqualTo( | ||
| UnboundTransform(Reference("created_at"), DayTransform()), | ||
| StringLiteral("2024-01-01"), | ||
| ) |
Contributor
There was a problem hiding this comment.
For testing, I think it would be good to have an integration test as well. The StringLiteral should be converted to a DateLiteral when bound to the transform.
Contributor
Author
There was a problem hiding this comment.
Added a unit test for this.
Collaborator
|
I've been playing around with this PR and I ran into something. Here's a quick demo script for your own testing. It looks like we're running into this issue because we coerce ts to a TimestampType at comparison time. That means the right side is |
rambleraptor
reviewed
Jun 3, 2026
| assert expected == parser.parse("CAST(created_at AS date) = '2024-01-01'") | ||
|
|
||
|
|
||
| def test_cast_date_binds_string_literal_to_date() -> None: |
Collaborator
There was a problem hiding this comment.
We should have more tests like this with uneven types. I posted an example in another comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #198
Picks up where #209 left off with @Fokko's feedback addressed. Thanks @jayceslesar for the original work.
Rationale for this change
Adds
CAST(column AS type)parsing that maps to Iceberg transforms (date→DayTransform,year→YearTransform,month→MonthTransform,hour→HourTransform). Also implementsBoundTransform.ref()andeval()— both were missing abstract methods required byBoundTerm. IntroducesUnboundTransformwithbind()that validates viacan_transform().Are these changes tested?
Yes. 11 new tests covering all transform types, case insensitivity, nested fields, unsupported types, comparison operators, and boolean composition.
Are there any user-facing changes?
No.