Skip to content

Commit dace8a7

Browse files
authored
feat: add avg, max, min to allowed functions (#210)
### TL;DR Added support for `avg`, `max`, and `min` functions to the allowed functions map. ### What changed? Added three new entries to the `allowedFunctions` map in `internal/common/utils.go`: - `avg`: for calculating averages - `max`: for finding maximum values - `min`: for finding minimum values These functions join the existing allowed functions like `sum`, `count`, `reinterpretasuint256`, `reverse`, and `unhex`. ### How to test? 1. Use these newly added functions in queries or operations where allowed functions are checked 2. Verify that operations using `avg`, `max`, and `min` now execute successfully 3. Confirm that the functions perform their expected calculations correctly ### Why make this change? These statistical functions are commonly needed for data analysis and aggregation operations. Adding them to the allowed functions map enables users to perform more sophisticated data processing without requiring custom implementations. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Expanded support for additional functions ("countDistinct", "avg", "max", "min") in query validation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 685b9d9 + bf71230 commit dace8a7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/common/utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func SliceToChunks[T any](values []T, chunkSize int) [][]T {
2525
var allowedFunctions = map[string]struct{}{
2626
"sum": {},
2727
"count": {},
28+
"countDistinct": {},
29+
"avg": {},
30+
"max": {},
31+
"min": {},
2832
"reinterpretasuint256": {},
2933
"reverse": {},
3034
"unhex": {},

0 commit comments

Comments
 (0)