Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5
perf(application): replace like_regex with == for tag filtering#516
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
Merged
arne-aignx
merged 2 commits into
main
from
task/PAPI-4862-optimize-application-runs-tag-queriesMar 27, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.14.1 | ||
| 3.14.2 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -711,14 +711,18 @@ def application_runs( # noqa: C901, PLR0912, PLR0913, PLR0914, PLR0915, PLR0917 | ||
| # Handle tags filter | ||
| if tags: | ||
| # JSONPath filter to match all of the provided tags in the sdk.tags array | ||
| # PostgreSQL limitation: Cannot use && between separate path expressions as backend crashes with 500 | ||
| # Workaround: Filter on backend for ANY tag match, then filter client-side for ALL | ||
| # Use regex alternation to match any of the tags | ||
| escaped_tags = [tag.replace('"', '\\"').replace("\\", "\\\\") for tag in tags] | ||
| # Create regex pattern: ^(tag1|tag2|tag3)$ | ||
| regex_pattern = "^(" + "|".join(escaped_tags) + ")$" | ||
| custom_metadata = f'$.sdk.tags ? (@ like_regex "{regex_pattern}")' | ||
| # Use equality checks instead of like_regex for exact tag matching. | ||
| # PostgreSQL GIN indexes (jsonb_path_ops) can accelerate == but not like_regex. | ||
| # PostgreSQL JSONPath does not support combining separate path expressions | ||
| # (e.g. $.sdk.tags ? (...) && $.sdk.note ? (...) is invalid JSONPath syntax), | ||
| # so we can only filter on one path per API call. | ||
| # Strategy: filter on backend for ANY tag match, then filter client-side for ALL. | ||
| escaped_tags = [tag.replace("\\", "\\\\").replace('"', '\\"') for tag in tags] | ||
| if len(escaped_tags) == 1: | ||
| custom_metadata = f'$.sdk.tags[*] ? (@ == "{escaped_tags[0]}")' | ||
| else: | ||
| conditions = " || ".join(f'@ == "{t}"' for t in escaped_tags) | ||
| custom_metadata = f"$.sdk.tags[*] ? ({conditions})" | ||
arne-aignx marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| run_iterator = self._get_platform_client().runs.list_data( | ||
| application_id=application_id, | ||
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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.