Skip to content

Commit b7ec72f

Browse files
authored
Merge pull request #137 from thirdweb-dev/01-28-allow_more_date_functions
allow more date functions and ordering for aggregations
2 parents 9538ef4 + d10ac08 commit b7ec72f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

internal/common/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ var allowedFunctions = map[string]struct{}{
170170
"length": {},
171171
"toUInt256": {},
172172
"if": {},
173+
"toStartOfMonth": {},
173174
"toStartOfDay": {},
175+
"toStartOfHour": {},
176+
"toStartOfMinute": {},
174177
"toDate": {},
175178
"concat": {},
176179
}

internal/storage/clickhouse.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,11 @@ func (c *ClickHouseConnector) GetAggregations(table string, qf QueryFilter) (Que
373373
query += fmt.Sprintf(" GROUP BY %s", groupByColumns)
374374
}
375375

376+
// Add ORDER BY clause
377+
if qf.SortBy != "" {
378+
query += fmt.Sprintf(" ORDER BY %s %s", qf.SortBy, qf.SortOrder)
379+
}
380+
376381
if err := common.ValidateQuery(query); err != nil {
377382
return QueryResult[interface{}]{}, err
378383
}

0 commit comments

Comments
 (0)