Skip to content

Commit

Permalink
Allow LIKE keyword to do partial term matching (uber#6490)
Browse files Browse the repository at this point in the history
  • Loading branch information
sankari165 authored Nov 12, 2024
1 parent a6c36bf commit 9d328c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/pinot/pinotQueryValidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (qv *VisibilityQueryValidator) processSystemKey(expr sqlparser.Expr) (strin
return "", fmt.Errorf("right comparison is invalid: %v", comparisonExpr.Right)
}
colValStr := string(colVal.Val)
return fmt.Sprintf("TEXT_MATCH(%s, '%s')", colNameStr, colValStr), nil
return fmt.Sprintf("TEXT_MATCH(%s, '/.*%s.*/')", colNameStr, colValStr), nil
}

if comparisonExpr.Operator != sqlparser.EqualStr && comparisonExpr.Operator != sqlparser.NotEqualStr {
Expand Down
4 changes: 2 additions & 2 deletions common/pinot/pinotQueryValidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestValidateQuery(t *testing.T) {
},
"Case2-2: simple query with partial match": {
query: "WorkflowID like 'wid'",
validated: "TEXT_MATCH(WorkflowID, 'wid')",
validated: "TEXT_MATCH(WorkflowID, '/.*wid.*/')",
},
"Case2-3: invalid simple query with partial match": {
query: "WorkflowID like wid",
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestValidateQuery(t *testing.T) {
},
"Case6-5: complex query with partial match": {
query: "RunID like '123' or WorkflowID like '123'",
validated: "(TEXT_MATCH(RunID, '123') or TEXT_MATCH(WorkflowID, '123'))",
validated: "(TEXT_MATCH(RunID, '/.*123.*/') or TEXT_MATCH(WorkflowID, '/.*123.*/'))",
},
"Case7: invalid sql query": {
query: "Invalid SQL",
Expand Down

0 comments on commit 9d328c7

Please sign in to comment.