vogievetsky opened a new issue #6751: Calcite column resolution bug
URL: https://github.com/apache/incubator-druid/issues/6751
 
 
   The following query fails:
   
   ```sql
   SELECT channel
   FROM "wikipedia"
   WHERE "user" IN (
       select "user" FROM (
           SELECT "user", count(*) AS "cnt"
           FROM "wikipedia"
           WHERE __time >= '2018-10-01' AND __time < '2018-11-01'
           GROUP BY 1
           HAVING "cnt" > 100
       )
   )
   GROUP BY 1
   ```
   
   With error: `Unknown exception: 
org.apache.calcite.runtime.CalciteContextException: From line 9, column 16 to 
line 9, column 20: Column 'cnt' not found in any table`
   
   This is incorrect, the "cnt" in the HAVING clause refers to the agg.
   This Query should work.
   
   Note that these queries work fine:
   
   Just the inner query:
   
   ```sql
   select "user" FROM (
       SELECT "user", count(*) AS "cnt"
       FROM "wikipedia"
       WHERE __time >= '2018-10-01' AND __time < '2018-11-01'
       GROUP BY 1
       HAVING "cnt" > 100
   )
   ```
   
   and the same query but with an agg in the HAVING
   
   ```sql
   SELECT channel
   FROM "wikipedia"
   WHERE "user" IN (
       select "user" FROM (
           SELECT "user", count(*) AS "cnt"
           FROM "wikipedia"
           WHERE __time >= '2018-10-01' AND __time < '2018-11-01'
           GROUP BY 1
           HAVING count(*) > 100
       )
   )
   GROUP BY 1
   ```
   
   This is tested on 0.13.0
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to