mihaibudiu commented on code in PR #4670: URL: https://github.com/apache/calcite/pull/4670#discussion_r2603816073
########## core/src/test/resources/sql/sub-query.iq: ########## @@ -5505,4 +5505,66 @@ WHERE EXISTS (2 rows) !ok + +# [CALCITE-7297] The result is incorrect when the GROUP BY key in a subquery is a RexFieldAccess +SELECT *, + (SELECT COUNT(*) + FROM + ( + SELECT empno, ename, job + FROM emp + WHERE emp.deptno = dept.deptno) AS sub + GROUP BY deptno) AS num_dept_groups +FROM dept; ++--------+------------+----------+-----------------+ +| DEPTNO | DNAME | LOC | NUM_DEPT_GROUPS | ++--------+------------+----------+-----------------+ +| 10 | ACCOUNTING | NEW YORK | 3 | +| 20 | RESEARCH | DALLAS | 5 | +| 30 | SALES | CHICAGO | 6 | +| 40 | OPERATIONS | BOSTON | | ++--------+------------+----------+-----------------+ +(4 rows) + +!ok + +# [CALCITE-7297] The result is incorrect when the GROUP BY key in a subquery is a RexFieldAccess +SELECT *, + (SELECT COUNT(*) + FROM + ( + SELECT empno, ename, job, comm + FROM emp + WHERE emp.deptno = dept.deptno + ORDER BY empno LIMIT 1 + ) AS sub + GROUP BY sub.comm + ) AS num_dept_groups +FROM dept; ++--------+------------+----------+-----------------+ +| DEPTNO | DNAME | LOC | NUM_DEPT_GROUPS | ++--------+------------+----------+-----------------+ +| 10 | ACCOUNTING | NEW YORK | 1 | +| 20 | RESEARCH | DALLAS | 1 | +| 30 | SALES | CHICAGO | 1 | +| 40 | OPERATIONS | BOSTON | | ++--------+------------+----------+-----------------+ +(4 rows) + +!ok + +# [CALCITE-7297] The result is incorrect when the GROUP BY key in a subquery is a RexFieldAccess Review Comment: can you use some input values with duplicates that produce an output with duplicates as well? (you can leave this test, but add a new one) That would make me feel a bit more confident -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
