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

Add more explicit interface to differentiate substring and full-string wildcard queries. #62

Merged
merged 7 commits into from
Jun 11, 2024

Conversation

LinZhihao-723
Copy link
Member

References

Description

As discussed in PR #27, users usually want the query to be automatically surrounded with wildcard * to match a substring. This PR implements such a query in a way we discussed and agreed on in PR #27. Essentially, this PR contains the following changes:

  • Redesign WildcardQuery classes. WildcardQuery is now marked as deprecated. Instead, users should use its derived class SubstringWildcardQuery and FullStringWildcardQuery to define a wildcard query. When using SubstringWildcardQuery, * prefix and postfix will be automatically added to match a substring.
  • Redesign QueryBuilder to change the method's signature of add_wildcard_query. It's taking a WildcardQuery class instead of a string and a boolean argument. The old signature can still be called but it is marked as deprecated.

We can support substring matches without breaking existing user code with the above implementations. In the future, we should also do the following cleanup:

Validation performed

  • All unit tests passed
  • Add unit tests to cover deprecated functions
  • CI passed, successfully built and tested across all the supported platforms and Python versions

@LinZhihao-723 LinZhihao-723 requested a review from junhaoliao June 3, 2024 17:41
Copy link
Member

@davidlion davidlion left a comment

Choose a reason for hiding this comment

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

Improve add_wildcard_query

Comment on lines 115 to 116
@no_type_check
def add_wildcard_query(self, *args: Tuple[Any, ...], **kwargs: Dict[str, Any]) -> QueryBuilder:
Copy link
Member

Choose a reason for hiding this comment

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

As discussed lets drop no_type_check and lets try a different approach.

Copy link
Member

@davidlion davidlion left a comment

Choose a reason for hiding this comment

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

Lets change the title + commit message to something more direct like:
Add more explicit interface to differentiate substring and full-string wildcard queries. (#62).

@LinZhihao-723
Copy link
Member Author

Lets change the title + commit message to something more direct like: Add more explicit interface to differentiate substring and full-string wildcard queries. (#62).

The commit msg lgtm, thx!

@LinZhihao-723 LinZhihao-723 changed the title Add support for Substring and Full string wildcard queries. Add more explicit interface to differentiate substring and full-string wildcard queries. Jun 11, 2024
@LinZhihao-723 LinZhihao-723 merged commit dba3db2 into y-scope:main Jun 11, 2024
60 checks passed
LinZhihao-723 added a commit that referenced this pull request Jun 13, 2024
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.

2 participants