feat(sql): add geomean() aggregate function#6656
Conversation
WalkthroughThis PR introduces a new geometric mean aggregate function ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code graph analysis (3)core/src/main/java/io/questdb/griffin/engine/functions/groupby/GeomeanDoubleGroupByFunctionFactory.java (2)
core/src/main/java/io/questdb/griffin/engine/functions/groupby/GeomeanDoubleGroupByFunction.java (3)
core/src/test/java/io/questdb/test/griffin/engine/functions/groupby/GeomeanDoubleGroupByFunctionFactoryTest.java (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (34)
🔇 Additional comments (16)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
[PR Coverage check]😍 pass : 64 / 73 (87.67%) file detail
|
Summary
Adds
geomean(double)aggregate function that computes the geometric mean of a set of positive numbers.exp(avg(ln(x)))- uses logarithms to avoid overflow with large productsgeomean(D)- accepts double (other numeric types implicitly convert)merge()for combining partial results across workersEdge cases (following DuckDB semantics)
nullln(negative)undefined)nullln(0)is undefinednullConstant folding optimization
When the argument is a constant, the factory returns
DoubleConstantdirectly sincegeomean(c) = cfor any positive constantc. This avoids aggregate machinery overhead.Test plan
geomean(2,8)=4,geomean(1,3,9)=3)geomean(x) = exp(avg(ln(x))))🤖 Generated with Claude Code