Julian Hyde 2013-09-09, 19:30
Yash Sharma 2013-09-10, 06:02
Julian Hyde 2013-09-10, 06:18
Ted Dunning 2013-09-09, 20:09
-Re: Exception while implementing drill trigonometric functions (For DRILL-219). Need tips.
On Sep 9, 2013, at 1:09 PM, Ted Dunning <[EMAIL PROTECTED]> wrote:
> I encountered the same problem adding things like AVG. Are aggregators
> handled the same way (and in the same place)?
I suspect it's a little bit different. First, AVG is already a built-in (as were some of the other functions that have recently been implemented in Drill, such as Abs and IS NOT NULL). So you probably saw a "cannot implement" exception rather than "unknown function".
Second, Although aggregate functions are defined in Optiq fairly similarly to regular functions (in terms of validating the number and type of parameters, overload resolution, deducing the return type), they are implemented differently because they need different code-generation.
But AVG isn't treated like a "typical" aggregate function. The built-in implementation of AVG treats it more like a macro, decomposing it into SUM / COUNT (taking special care when COUNT is 0), so code-generation is not required.
There are very few "typical" aggregate functions. I'm sure Drill & Optiq will want to allow user-defined aggregate functions at some point, but they are likely to be a compromise in terms of type-deduction and performance.