Skip to content

Commit

Permalink
Update ListAllWorkflowExecutions pinot endpoint (#6160)
Browse files Browse the repository at this point in the history
* Update ListAllWorkflowExecutions pinot endpoint

* address comments
  • Loading branch information
sankari165 authored Jul 8, 2024
1 parent 1a86de7 commit 1e2ef3d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
31 changes: 15 additions & 16 deletions common/persistence/pinot/pinot_visibility_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
30 changes: 15 additions & 15 deletions common/persistence/pinot/pinot_visibility_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1e2ef3d

Please sign in to comment.