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