diff --git a/common/persistence/pinot/pinot_visibility_store.go b/common/persistence/pinot/pinot_visibility_store.go index 6d6a082eb82..cdfe894f044 100644 --- a/common/persistence/pinot/pinot_visibility_store.go +++ b/common/persistence/pinot/pinot_visibility_store.go @@ -720,20 +720,19 @@ func (s *PinotQuerySearchField) resetSearchField() { func (s *PinotQuerySearchField) addEqual(obj string, val interface{}) { s.checkFirstSearchField() - if _, ok := val.(string); ok { - val = fmt.Sprintf("'%s'", val) - } else { - val = fmt.Sprintf("%v", val) + switch val.(type) { + case string: + s.string += fmt.Sprintf("%s = '%s'\n", obj, val) + case int32: + s.string += fmt.Sprintf("%s = %d\n", obj, val) + default: + s.string += fmt.Sprintf("%s = %v\n", obj, val) } - - quotedVal := fmt.Sprintf("%s", val) - s.string += fmt.Sprintf("%s = %s\n", obj, quotedVal) } func (s *PinotQuerySearchField) addMatch(obj string, val interface{}) { s.checkFirstSearchField() - - s.string += fmt.Sprintf("text_match(%s, '\"%s\"')\n", obj, val) + s.string += fmt.Sprintf("REGEXP_LIKE(%s, '^.*%s.*$')\n", obj, val) } func NewPinotQuery(tableName string) PinotQuery { @@ -778,7 +777,7 @@ func (q *PinotQuery) addOffsetAndLimits(offset int, limit int) { func (q *PinotQuery) addStatusFilters(status []types.WorkflowExecutionCloseStatus) { for _, s := range status { - q.search.addEqual(CloseStatus, s.String()) + q.search.addEqual(CloseStatus, int32(s)) } q.search.lastSearchField() @@ -1094,13 +1093,13 @@ func (v *pinotVisibilityStore) getListAllWorkflowExecutionsQuery(tableName strin if request.WorkflowSearchValue != "" { if request.PartialMatch { - query.search.addMatch(WorkflowID, request.WorkflowSearchValue) - query.search.addMatch(WorkflowType, request.WorkflowSearchValue) - query.search.addMatch(RunID, request.WorkflowSearchValue) + query.search.addMatch(WfIDTextSearch, request.WorkflowSearchValue) + query.search.addMatch(WfTypeTextSearch, request.WorkflowSearchValue) + query.search.addMatch(RunIDTextSearch, request.WorkflowSearchValue) } else { - query.search.addEqual(WorkflowID, request.WorkflowSearchValue) - query.search.addEqual(WorkflowType, request.WorkflowSearchValue) - query.search.addEqual(RunID, request.WorkflowSearchValue) + query.search.addEqual(WfIDTextSearch, request.WorkflowSearchValue) + query.search.addEqual(WfTypeTextSearch, request.WorkflowSearchValue) + query.search.addEqual(RunIDTextSearch, request.WorkflowSearchValue) } query.search.lastSearchField() diff --git a/common/persistence/pinot/pinot_visibility_store_test.go b/common/persistence/pinot/pinot_visibility_store_test.go index 87610974ac8..4a74afe09b0 100644 --- a/common/persistence/pinot/pinot_visibility_store_test.go +++ b/common/persistence/pinot/pinot_visibility_store_test.go @@ -1776,12 +1776,12 @@ FROM %s WHERE DomainID = 'bfd5c907-f899-4baf-a7b2-2ab85e623ebd' AND IsDeleted = false AND StartTime BETWEEN 1547596871371 AND 2547596873371 -AND ( CloseStatus = 'COMPLETED' -OR CloseStatus = 'TIMED_OUT' +AND ( CloseStatus = 0 +OR CloseStatus = 5 ) -AND ( WorkflowID = '123' -OR WorkflowType = '123' -OR RunID = '123' +AND ( WorkflowIDTextSearch = '123' +OR WorkflowTypeTextSearch = '123' +OR RunIDTextSearch = '123' ) Order BY StartTime DESC LIMIT 0, 10 @@ -1809,11 +1809,11 @@ FROM %s WHERE DomainID = 'bfd5c907-f899-4baf-a7b2-2ab85e623ebd' AND IsDeleted = false AND StartTime BETWEEN 1547596871371 AND 2547596873371 -AND ( CloseStatus = 'TERMINATED' +AND ( CloseStatus = 3 ) -AND ( WorkflowID = '123' -OR WorkflowType = '123' -OR RunID = '123' +AND ( WorkflowIDTextSearch = '123' +OR WorkflowTypeTextSearch = '123' +OR RunIDTextSearch = '123' ) Order BY CloseTime ASC LIMIT 0, 10 @@ -1840,9 +1840,9 @@ FROM %s WHERE DomainID = 'bfd5c907-f899-4baf-a7b2-2ab85e623ebd' AND IsDeleted = false AND StartTime BETWEEN 1547596871371 AND 2547596873371 -AND ( WorkflowID = '123' -OR WorkflowType = '123' -OR RunID = '123' +AND ( WorkflowIDTextSearch = '123' +OR WorkflowTypeTextSearch = '123' +OR RunIDTextSearch = '123' ) Order BY StartTime DESC LIMIT 0, 10 @@ -1867,9 +1867,9 @@ FROM %s WHERE DomainID = 'bfd5c907-f899-4baf-a7b2-2ab85e623ebd' AND IsDeleted = false AND StartTime BETWEEN 1547596871371 AND 2547596873371 -AND ( text_match(WorkflowID, '"123"') -OR text_match(WorkflowType, '"123"') -OR text_match(RunID, '"123"') +AND ( REGEXP_LIKE(WorkflowIDTextSearch, '^.*123.*$') +OR REGEXP_LIKE(WorkflowTypeTextSearch, '^.*123.*$') +OR REGEXP_LIKE(RunIDTextSearch, '^.*123.*$') ) Order BY StartTime DESC LIMIT 0, 10