Here's one more example how SUM0 complicates things for enumerable convention: https://github.com/julianhyde/optiq/pull/303 (see generated code for testWinAgg)
> (b) pushing the process down to another engine, perhaps SQL The standard SQL has no such thing as SUM0. Try pushing it down to Oracle DB and you are done. >(c) computing rolling sum, by adding to a total as rows enter a window and subtracting from a total as rows leave. Optiq is doing that already (except subtracting from a total as rows leave part), and SUM0 just complicates things here. I understand Optiq is not the only runtime, however I still believe just having a single SUM is easier. > perhaps another language such as MongoDB Do you mean like this one https://twitter.com/julianhyde/status/461967033115373569? Does MongoDB support SUM0 better than SUM? Timothy wrote as follows ( https://groups.google.com/d/msg/optiq-dev/_UMt5UjhgAs/3LlU9wWexRMJ ): > I'm not sure why Optiq wants to replace the agg call with a $SUM0? This is causing Drill to not able to find the SUM function call. >until we know whether we prefer the SUM form? We might try use the same approach as for AVG expansion (expand SUM to SUM0 if the implementation raises "unable to implement SUM, please use SUM0"), however SUM0 support is fragile and it is easy to mess with data type nullability (see RexBuidler.makeOver) That said, I suggest dodging SUM0. If we do so during repackage, we can just delete all the SUM0 references. Otherwise we can just avoid generation of SUM0 and kill the references in the next release. ​Vladimir
