Skip to content

Conversation

@LuigiCerone
Copy link
Contributor

Closes #6112

@LuigiCerone LuigiCerone changed the title Python expressions Python starts_with and not_starts_with expressions Feb 21, 2023
@Fokko Fokko added this to the PyIceberg 0.4.0 release milestone Feb 21, 2023
@Fokko Fokko changed the title Python starts_with and not_starts_with expressions Python: starts_with and not_starts_with expressions Feb 21, 2023
@LuigiCerone LuigiCerone marked this pull request as ready for review February 23, 2023 16:28
Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up @LuigiCerone I've added some suggestions for more test cases, would you be able to port those over from Java? Thanks!



def test_starts_with() -> None:
assert StartsWith("x", "data") == parser.parse("x starts_with 'data'")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think starts_with is common in SQL. How about:

Suggested change
assert StartsWith("x", "data") == parser.parse("x starts_with 'data'")
assert StartsWith("x", "data") == parser.parse("x LIKE 'data*'")

Copy link
Contributor Author

@LuigiCerone LuigiCerone Feb 24, 2023

Choose a reason for hiding this comment

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

Yes you are right about the fact that starts_with is not common in SQL. I'm just afraid that LIKE is a little misleading because in SQL it's to look for a pattern in the whole string whereas here it would just be to look for "starts with".

@LuigiCerone LuigiCerone marked this pull request as draft February 24, 2023 07:06
@LuigiCerone LuigiCerone force-pushed the python_expressions branch 2 times, most recently from e7d394e to 4a73eae Compare February 24, 2023 14:24
@LuigiCerone LuigiCerone marked this pull request as ready for review February 24, 2023 14:30
@LuigiCerone LuigiCerone marked this pull request as draft February 28, 2023 10:12
@LuigiCerone
Copy link
Contributor Author

LuigiCerone commented Feb 28, 2023

Need to update python/tests/expressions/test_evaluator.py according to new syntax. I will work on it asap.

@LuigiCerone LuigiCerone marked this pull request as ready for review March 1, 2023 07:36
@LuigiCerone LuigiCerone requested a review from Fokko March 1, 2023 13:34
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

A few minor nits, but apart from that it looks great. Thanks for picking this up @LuigiCerone!

LuigiCerone and others added 2 commits March 2, 2023 08:42
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

Thanks @LuigiCerone for fixing this! Much appreciated!

@Fokko Fokko merged commit fa0bcdf into apache:master Mar 2, 2023
krvikash pushed a commit to krvikash/iceberg that referenced this pull request Mar 16, 2023
* Add new expressions

* Add test for new expressions

* Fix tests and test visitors

* Add py arrow tests

* Fix visitors, fix mypy

* Fix problem on ManifestEvalVisitor

* Update python/pyiceberg/expressions/visitors.py

Co-authored-by: Fokko Driesprong <fokko@apache.org>

* Update python/tests/expressions/test_parser.py

Co-authored-by: Fokko Driesprong <fokko@apache.org>

* Fix test_parser tests and add more test_evaluator tests for new python operators

* Fix ManifestEvalVisitor logic, add more tests

* Fixes and minors from review

* Add MetricsEvaluator starts_with logic and fix tests

* Apply suggestions from code review

Co-authored-by: Fokko Driesprong <fokko@apache.org>

* Apply suggestions from code review

Co-authored-by: Fokko Driesprong <fokko@apache.org>

* Fix mypy error

---------

Co-authored-by: Luigi Cerone <luigi.cerone@facile.it>
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add StartsWith and NotStartsWith operator to PyIceberg

3 participants