From 0dd87b0f2faa1614d5def7003c474e53283e6ce9 Mon Sep 17 00:00:00 2001 From: sankari gopalakrishnan Date: Fri, 5 Jul 2024 13:56:38 +0200 Subject: [PATCH 1/2] Update ListAllWorkflowExecutions pinot endpoint --- .../pinot/pinot_visibility_store.go | 26 ++++++++-------- .../pinot/pinot_visibility_store_test.go | 30 +++++++++---------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/common/persistence/pinot/pinot_visibility_store.go b/common/persistence/pinot/pinot_visibility_store.go index 6d6a082eb82..b5246c94162 100644 --- a/common/persistence/pinot/pinot_visibility_store.go +++ b/common/persistence/pinot/pinot_visibility_store.go @@ -721,19 +721,17 @@ func (s *PinotQuerySearchField) resetSearchField() { func (s *PinotQuerySearchField) addEqual(obj string, val interface{}) { s.checkFirstSearchField() if _, ok := val.(string); ok { - val = fmt.Sprintf("'%s'", val) + s.string += fmt.Sprintf("%s = '%s'\n", obj, val) + } else if _, ok = val.(int32); ok { + s.string += fmt.Sprintf("%s = %d\n", obj, val) } else { - val = fmt.Sprintf("%v", val) + 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 +776,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 +1092,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 From f9ec2651d26df3e0e413dc1b1b061ed8e438f7ad Mon Sep 17 00:00:00 2001 From: sankari gopalakrishnan Date: Mon, 8 Jul 2024 11:37:10 +0200 Subject: [PATCH 2/2] address comments --- common/persistence/pinot/pinot_visibility_store.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/persistence/pinot/pinot_visibility_store.go b/common/persistence/pinot/pinot_visibility_store.go index b5246c94162..cdfe894f044 100644 --- a/common/persistence/pinot/pinot_visibility_store.go +++ b/common/persistence/pinot/pinot_visibility_store.go @@ -720,11 +720,12 @@ func (s *PinotQuerySearchField) resetSearchField() { func (s *PinotQuerySearchField) addEqual(obj string, val interface{}) { s.checkFirstSearchField() - if _, ok := val.(string); ok { + switch val.(type) { + case string: s.string += fmt.Sprintf("%s = '%s'\n", obj, val) - } else if _, ok = val.(int32); ok { + case int32: s.string += fmt.Sprintf("%s = %d\n", obj, val) - } else { + default: s.string += fmt.Sprintf("%s = %v\n", obj, val) } }