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 regex support to query syntax #164

Merged
merged 1 commit into from
Oct 30, 2023
Merged

Add regex support to query syntax #164

merged 1 commit into from
Oct 30, 2023

Conversation

codchen
Copy link
Collaborator

@codchen codchen commented Oct 27, 2023

Describe your changes and provide context

Add regex syntax so that queries like tx.topics MATCHES '\[.*,xyz,.*\]' can be written and executed correctly

Testing performed to validate your change

unit tests

@codchen codchen requested review from jewei1997 and Kbhat1 October 27, 2023 02:43
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #164 (b455a98) into main (962ce07) will decrease coverage by 0.07%.
The diff coverage is 62.50%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #164      +/-   ##
==========================================
- Coverage   59.10%   59.04%   -0.07%     
==========================================
  Files         281      281              
  Lines       38858    38913      +55     
==========================================
+ Hits        22968    22976       +8     
- Misses      14101    14138      +37     
- Partials     1789     1799      +10     
Files Coverage Δ
internal/pubsub/query/query.go 66.31% <100.00%> (+0.91%) ⬆️
internal/pubsub/query/syntax/parser.go 70.76% <100.00%> (+0.45%) ⬆️
internal/pubsub/query/syntax/scanner.go 81.18% <100.00%> (+0.20%) ⬆️
internal/state/indexer/tx/kv/kv.go 68.86% <60.00%> (-0.50%) ⬇️
internal/state/indexer/block/kv/kv.go 57.14% <50.00%> (-0.60%) ⬇️

... and 19 files with indirect coverage changes

@jewei1997
Copy link
Contributor

if we want this to be specifically the 2nd topic, wouldn't a regex like '\[.*,xyz,.*\]' work for cases where it is the 2nd or 3rd topic? I think we might need to do exclude commas in the first .* to make sure xyz is the second topic.

@codchen
Copy link
Collaborator Author

codchen commented Oct 27, 2023

if we want this to be specifically the 2nd topic, wouldn't a regex like '\[.*,xyz,.*\]' work for cases where it is the 2nd or 3rd topic? I think we might need to do exclude commas in the first .* to make sure xyz is the second topic.

yeah exactly we need to exclude comma from the wildcard

Copy link
Contributor

@Kbhat1 Kbhat1 left a comment

Choose a reason for hiding this comment

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

LGTM, we tested this on a node too right?

@jewei1997
Copy link
Contributor

if we want this to be specifically the 2nd topic, wouldn't a regex like '\[.*,xyz,.*\]' work for cases where it is the 2nd or 3rd topic? I think we might need to do exclude commas in the first .* to make sure xyz is the second topic.

yeah exactly we need to exclude comma from the wildcard

Oh I see this is just adding general regex support.

@codchen
Copy link
Collaborator Author

codchen commented Oct 30, 2023

LGTM, we tested this on a node too right?

yeah tested rpc request Events against local node

@codchen codchen merged commit 265f357 into main Oct 30, 2023
24 checks passed
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