Cool, can you create an issue for this bug?

- Haisheng

------------------------------------------------------------------
发件人:Muhammad Gelbana<m.gelb...@gmail.com>
日 期:2019年06月12日 02:39:20
收件人:dev@calcite.apache.org (dev@calcite.apache.org)<dev@calcite.apache.org>
抄 送:Haisheng Yuan<h.y...@alibaba-inc.com>
主 题:Re: How to avoid SUM0 or disable a rule ?

I believe it's a bug because DoubleSum (Also LongSum and IntSum) are 
initialized with a value of 0 [1]

[1] 
https://github.com/apache/calcite/blob/a3c56be7bccc58859524ba39e5b30b7078f97d00/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java#L459

Thanks,
Gelbana

On Tue, Jun 11, 2019 at 8:35 PM Vamshi Krishna <vamshi.v.kris...@gmail.com> 
wrote:
It's done in the SqlToRelConverter.java:5427. I don't think there is a
 way currently to disable it (i may be wrong).
 There should be a configurable option to disable this.


 -Vamshi

 On Tue, Jun 11, 2019 at 2:31 PM Muhammad Gelbana <m.gelb...@gmail.com> wrote:
 >
 > I just cleared the reducible aggregate calls collection at runtime (to void
 > the rule) and I'm still facing the same problem. This onviously has nothing
 > to do with the rule. I'll investigate further. Thanks for your help.
 >
 > Thanks,
 > Gelbana
 >
 >
 > On Tue, Jun 11, 2019 at 8:16 PM Haisheng Yuan <h.y...@alibaba-inc.com>
 > wrote:
 >
 > > Hi Gelbana,
 > >
 > > You can construct your own AggregateReduceFunctionsRule instance by
 > > specifying the functions you want to reduce:
 > >
 > > public AggregateReduceFunctionsRule(Class<? extends Aggregate> 
 > > aggregateClass,
 > >     RelBuilderFactory relBuilderFactory, EnumSet<SqlKind> 
 > > functionsToReduce) {
 > >
 > >
 > > But I think the issue you described might be a bug, can you open a JIRA
 > > issue with a test case if possible?
 > >
 > > - Haisheng
 > >
 > > ------------------------------------------------------------------
 > > 发件人:Muhammad Gelbana<m.gelb...@gmail.com>
 > > 日 期:2019年06月12日 01:46:28
 > > 收件人:<dev@calcite.apache.org>
 > > 主 题:How to avoid SUM0 or disable a rule ?
 > >
 > > Executing the following query produces unexpected results
 > >
 > > SELECT
 > >     "Calcs"."key" AS "key",
 > >     SUM("Calcs"."num2") AS "sum:num2:ok",
 > >     SUM("Calcs"."num2") AS "$__alias__0"
 > > FROM "TestV1"."Calcs" "Calcs"
 > > GROUP BY 1
 > > ORDER BY 3 ASC NULLS FIRST
 > > LIMIT 10
 > >
 > > The returned results contains 0 instead of NULLs while running the query
 > > against a PostgreSQL instance returns NULLs as expected.
 > >
 > >
 > > The reason for that is that Calcite uses SUM0 implementation instead of 
 > > SUM.
 > > I found that the AggregateReduceFunctionsRule rule is the one that converts
 > > the SUM aggregate call to SUM0, so is there a way to remove this rule
 > > before planning ?
 > >
 > > Thanks,
 > > Gelbana
 > >
 > >

Reply via email to