Zhen Chen created CALCITE-7386:
----------------------------------

             Summary: An error occurred while using TopDownGeneralDecorrelator 
to process the aggregate(col) filter
                 Key: CALCITE-7386
                 URL: https://issues.apache.org/jira/browse/CALCITE-7386
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Zhen Chen


An error will occur when executing the following SQL in CoreQuidemTest2.
{code:java}
# Measure with FILTER
select job,
    c,
    aggregate(avg_sal) as avg_sal,
    aggregate(c) filter (where deptno = 20) as c2,
    aggregate(avg_sal) filter (where deptno = 20) as avg_sal2
from (
  select *, count(*) as measure c, avg(sal) as measure avg_sal
  from "scott".emp
  where job <> 'PRESIDENT')
where deptno < 25
group by job;
+---------+---+---------+----+----------+
| JOB     | C | AVG_SAL | C2 | AVG_SAL2 |
+---------+---+---------+----+----------+
| ANALYST | 2 | 3000.00 |  2 |  3000.00 |
| CLERK   | 4 | 1037.50 |  2 |   950.00 |
| MANAGER | 3 | 2758.33 |  1 |  2975.00 |
+---------+---+---------+----+----------+
(3 rows)!ok {code}
The result is error.

< | CLERK   | 4 | 1037.50 |  2 |   950.00 |
< | MANAGER | 3 | 2758.33 |  1 |  2975.00 |
---
> | CLERK   | 3 | 1066.66 |  2 |   950.00 |
> | MANAGER | 2 | 2712.50 |  1 |  2975.00 |

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to