feat: Add CONTAINS and NOT CONTAINS operators for substring matching #3
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.
What was changed
Add support for
CONTAINSandNOT CONTAINSoperators to enable substring matching in SQL queries.Changes:
token.go: Registercontainsas a reserved keywordast.go: AddContainsStrandNotContainsStroperator constantssql.y: AddCONTAINSto operator precedence and grammar rulessql.go: Regenerate parser from updated grammar using goyaccExample usage:
Why?
Currently, the parser only supports prefix matching via
STARTS_WITH. This limitation makes it difficult to perform substring searches within field values, which is a common filtering use case.Use case: Users need to find all workflows containing a specific substring in their WorkflowId or WorkflowType. For example:
atom-agent-azure-ad-1,service-azure-ad-sync,azure-ad-integration-v2by searching for substring"azure-ad"STARTS_WITHalone since the substring may appear anywhere in the valueThe
CONTAINSoperator complementsSTARTS_WITHby enabling substring matching at any position, providing more flexible filtering capabilities.Related Changes
This PR is part of a feature implementation across multiple repositories:
CONTAINSoperator to SQL grammarCONTAINSin visibility query convertersCONTAINS→ SQLLIKE '%value%'for SQL databasesCONTAINS→ ElasticsearchWildcardQuery("*value*")All three PRs need to be merged together for the feature to work end-to-end.
Checklist
Closes #[issue number if exists]
How was this tested:
CONTAINSkeywordCONTAINSandNOT CONTAINSexpressionsCONTAINSandNOT CONTAINSvariantsWorkflowId CONTAINS "azure-ad"returns correct resultsAny docs updates needed?
Implementation Notes
STARTS_WITHoperatorsql.gois auto-generated by goyacc and is expected