You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2024/08/12 18:00:00 UTC

[jira] [Created] (CALCITE-6525) Query with one-to-many join of measure to regular table

Julian Hyde created CALCITE-6525:
------------------------------------

             Summary: Query with one-to-many join of measure to regular table
                 Key: CALCITE-6525
                 URL: https://issues.apache.org/jira/browse/CALCITE-6525
             Project: Calcite
          Issue Type: Improvement
            Reporter: Julian Hyde


The following query has one-to-many join of a table with a measure ({{deptm}}) to regular table ({{emp}}):
{code}
with deptm as
  (select deptno, dname, avg(char_length(dname)) as measure m
   from dept)
select aggregate(m) as m
from deptm join emp using (deptno);
{code}

The result should preserve the grain of the measure, that is, include each department once in the {{AVG}}, not give more weight to departments with more employees. To that end, the expanded query should include something like {{avg(char_length(d.dname)) within distinct (d.deptno)}}.



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