Skip to content

Commit

Permalink
Add limit clause to pinot queries (#5337)
Browse files Browse the repository at this point in the history
* add limit clause to queries

* cleanup: run make copyright things
  • Loading branch information
bowenxia authored and neil-xie committed Aug 15, 2023
1 parent 94908a6 commit 66e9a04
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions common/persistence/Pinot/pinotVisibilityStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,16 @@ func getListWorkflowExecutionsByTypeQuery(tableName string, request *p.InternalL

//query.addPinotSorter(CloseTime, DescendingOrder)
//query.addPinotSorter(RunID, DescendingOrder)

token, err := pnt.GetNextPageToken(request.NextPageToken)
if err != nil {
panic(fmt.Sprintf("deserialize next page token error: %s", err))
}

from := token.From
pageSize := request.PageSize
query.addOffsetAndLimits(from, pageSize)

return query.String()
}

Expand All @@ -958,6 +968,16 @@ func getListWorkflowExecutionsByWorkflowIDQuery(tableName string, request *p.Int

query.addPinotSorter(CloseTime, DescendingOrder)
//query.addPinotSorter(RunID, DescendingOrder)

token, err := pnt.GetNextPageToken(request.NextPageToken)
if err != nil {
panic(fmt.Sprintf("deserialize next page token error: %s", err))
}

from := token.From
pageSize := request.PageSize
query.addOffsetAndLimits(from, pageSize)

return query.String()
}

Expand Down Expand Up @@ -991,6 +1011,16 @@ func getListWorkflowExecutionsByStatusQuery(tableName string, request *p.Interna

query.addPinotSorter(CloseTime, DescendingOrder)
//query.addPinotSorter(RunID, DescendingOrder)

token, err := pnt.GetNextPageToken(request.NextPageToken)
if err != nil {
panic(fmt.Sprintf("deserialize next page token error: %s", err))
}

from := token.From
pageSize := request.PageSize
query.addOffsetAndLimits(from, pageSize)

return query.String()
}

Expand Down
5 changes: 5 additions & 0 deletions common/persistence/Pinot/pinotVisibilityStore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ AND WorkflowType = 'test-wf-type'
AND CloseTime BETWEEN 1547596871371 AND 2547596873371
AND CloseStatus >= 0
Order BY CloseTime DESC
LIMIT 0, 10
`, testTableName)
expectOpenResult := fmt.Sprintf(`SELECT *
FROM %s
Expand All @@ -395,6 +396,7 @@ AND StartTime BETWEEN 1547596871371 AND 2547596873371
AND CloseStatus < 0
AND CloseTime = -1
Order BY RunID DESC
LIMIT 0, 10
`, testTableName)
expectNilResult := ""

Expand Down Expand Up @@ -426,6 +428,7 @@ AND WorkflowID = 'test-wid'
AND CloseTime BETWEEN 1547596871371 AND 2547596873371
AND CloseStatus >= 0
Order BY CloseTime DESC
LIMIT 0, 10
`, testTableName)
expectOpenResult := fmt.Sprintf(`SELECT *
FROM %s
Expand All @@ -435,6 +438,7 @@ AND StartTime BETWEEN 1547596871371 AND 2547596873371
AND CloseStatus < 0
AND CloseTime = -1
Order BY CloseTime DESC
LIMIT 0, 10
`, testTableName)
expectNilResult := ""

Expand Down Expand Up @@ -464,6 +468,7 @@ WHERE DomainID = 'bfd5c907-f899-4baf-a7b2-2ab85e623ebd'
AND CloseStatus = '0'
AND CloseTime BETWEEN 1547596872371 AND 2547596872371
Order BY CloseTime DESC
LIMIT 0, 10
`, testTableName)
expectNilResult := ""

Expand Down

0 comments on commit 66e9a04

Please sign in to comment.