Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update like statements to reflect sql behaviors #91

Merged
merged 6 commits into from
Oct 21, 2023

Conversation

danielcweeks
Copy link
Contributor

No description provided.

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.

Apart from a few nits, this looks great @danielcweeks. Thanks for fixing this 👍

with pytest.raises(ValueError) as exc_info:
parser.parse(statement)

assert "LIKE expressions only supports wildcard, '%', at the end of a string" in str(exc_info)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one, this was one of my concerns 👍

pyiceberg/expressions/parser.py Outdated Show resolved Hide resolved
tests/expressions/test_parser.py Outdated Show resolved Hide resolved
@@ -78,6 +78,8 @@
identifier = Word(alphas, alphanums + "_$").set_results_name("identifier")
column = DelimitedList(identifier, delim=".", combine=False).set_results_name("column")

like_regex = r'(?P<valid_wildcard>(?<!\\)%$)|(?P<invalid_wildcard>(?<!\\)%)'
Copy link
Contributor

Choose a reason for hiding this comment

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

My first choice would not be a regex, but it works well 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to complicate the parser, so this seemed like the most straightforward path.

@Fokko Fokko added this to the PyIceberg 0.5.1 release milestone Oct 21, 2023
danielcweeks and others added 2 commits October 21, 2023 15:30
@danielcweeks danielcweeks merged commit b6c1b02 into apache:main Oct 21, 2023
6 checks passed
@danielcweeks danielcweeks deleted the fix/sql-parse branch October 21, 2023 22:38
Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

I'm late to this but took a pass, and LGTM. thanks @danielcweeks

Fokko added a commit that referenced this pull request Oct 24, 2023
* Update like statements to reflect sql behaciors

* Codestyle

* Codestyle

* Handle NotStartsWith

* Update pyiceberg/expressions/parser.py

Co-authored-by: Fokko Driesprong <[email protected]>

* Update tests/expressions/test_parser.py

Co-authored-by: Fokko Driesprong <[email protected]>

---------

Co-authored-by: Fokko Driesprong <[email protected]>
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