calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eli Levine <elilev...@gmail.com>
Subject Re: Column missing from COUNT(column)
Date Thu, 02 Feb 2017 23:19:03 GMT
It was indeed a case of Calcite optimizing COUNT of NOT NULL columns.
Thanks for the pointers, Gian and Gautam!

On Thu, Feb 2, 2017 at 2:53 PM, Gautam Parai <gparai@mapr.com> wrote:

> The same query on Drill executes correctly. Hence, the logical plan should
> be correct. Maybe the COUNT(sal) converted to COUNT(*) because sal is NOT
> NULL.
>
> ________________________________
> From: Eli Levine <elilevine@gmail.com>
> Sent: Thursday, February 2, 2017 2:29:06 PM
> To: dev@calcite.apache.org
> Subject: Column missing from COUNT(column)
>
> Greetings! I have encountered what appears to be a bug in Calcite while
> working on the Pig adapter [1].
>
> This query:
>
> select deptno + 4, sum(sal), sum(3 + sal), 2 * count(sal)
> from emp
> group by deptno
>
> produces the following plan:
>
> LogicalProject(EXPR$0=[+($0, 4)], EXPR$1=[$1], EXPR$2=[$2], EXPR$3=[*(2,
> $3)])
>   LogicalAggregate(group=[{0}], EXPR$1=[SUM($1)], EXPR$2=[SUM($2)],
> agg#2=[COUNT()])
>     LogicalProject(DEPTNO=[$7], SAL=[$5], $f2=[+(3, $5)])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>
> Note that the COUNT aggregate call does not have an associated column
> reference, unlike other aggregate calls. Is this expected? Poking around
> SqlToRelConverter is proving fairly involved, so I would like to make sure
> this is actually an issue before sinking more time into it.
>
> Thanks!
>
> Eli
>
> [1] https://issues.apache.org/jira/browse/CALCITE-1598
>
> <https://issues.apache.org/jira/browse/CALCITE-1598>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message