-
Notifications
You must be signed in to change notification settings - Fork 16
feat: add avg, max, min to allowed functions #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe update expands the set of recognized allowed function names in the query validation logic by adding "countDistinct" along with "avg", "max", and "min" to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant QueryValidator
User->>QueryValidator: Submit query with function (e.g., "countDistinct", "avg", "max", "min")
QueryValidator->>QueryValidator: Check if function is in allowedFunctions
alt Function is allowed
QueryValidator-->>User: Accept query
else Function not allowed
QueryValidator-->>User: Reject query
end
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/common/utils.go (1)
28-30
: Correctly included “avg”, “max”, and “min” in allowedFunctions.The new aggregation functions match the PR objectives and integrate cleanly with the existing validation logic.
Ensure that:
- Unit tests for
ValidateQuery
are updated to cover these three functions.- Any documentation or code comments listing supported functions are updated accordingly.
- (Optional) For maintainability, consider alphabetically ordering or logically grouping entries in
allowedFunctions
.Would you like me to generate the corresponding test cases and update documentation?
2cc8acf
to
bf71230
Compare
TL;DR
Added support for
avg
,max
, andmin
functions to the allowed functions map.What changed?
Added three new entries to the
allowedFunctions
map ininternal/common/utils.go
:avg
: for calculating averagesmax
: for finding maximum valuesmin
: for finding minimum valuesThese functions join the existing allowed functions like
sum
,count
,reinterpretasuint256
,reverse
, andunhex
.How to test?
avg
,max
, andmin
now execute successfullyWhy 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.
Summary by CodeRabbit