Skip to content

Commit 80b4abe

Browse files
committed
limit for aggregations
1 parent e5f7511 commit 80b4abe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/storage/clickhouse.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ func (c *ClickHouseConnector) GetAggregations(table string, qf QueryFilter) (Que
504504
query += fmt.Sprintf(" ORDER BY %s %s", qf.SortBy, qf.SortOrder)
505505
}
506506

507+
// Add limit clause
508+
if qf.Page > 0 && qf.Limit > 0 {
509+
offset := (qf.Page - 1) * qf.Limit
510+
query += fmt.Sprintf(" LIMIT %d OFFSET %d", qf.Limit, offset)
511+
} else if qf.Limit > 0 {
512+
query += fmt.Sprintf(" LIMIT %d", qf.Limit)
513+
}
514+
507515
if err := common.ValidateQuery(query); err != nil {
508516
return QueryResult[interface{}]{}, err
509517
}

0 commit comments

Comments
 (0)