:wave: Team. Have one question. I found from the d...
# troubleshooting
j
👋 Team. Have one question. I found from the doc that we can technically use
HAVING
clause (here). However when I try it, I receive the following error message. The query I tried was the same as what was written in the doc. Is this something new that we need to upgrade?
Copy code
Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered "HAVING" at line 11, column 1.
Was expecting one of:
    <EOF> 
    "LIMIT" ...
    "OFFSET" ...
...
m
This is not a new feature, so expect to work. What image are you using?
j
👋 Are you asking the version? We're using 0.10.0
m
Yes, was asking version. Paste the exact query, and any other non-default features you may have enabled?
j
So.. this is the query I tried (with a different value)
Copy code
SELECT 
	SUM(my_count) as counts,
    my_term
FROM my_table
WHERE 
	shop_id = 123 AND
	listing_id = 12345 AND
	serve_time BETWEEN 1661918400 AND 1662004800
GROUP BY my_term 
ORDER BY SUM(my_count) DESC
HAVING SUM(my_count) >= 5
LIMIT 100000;
And encountered the error above
any other non-default features you may have enabled
I don't think so? What are some of the non-default features for example?
x
try move
HAVING
before
ORDER BY
like below? It worked on my side (with latest master branch btw).
Copy code
SELECT 
    AirlineID,
	sum(DepDelay) as value
FROM airlineStats
GROUP BY AirlineID 
HAVING sum(DepDelay) >= 0
ORDER BY value DESC
I got same error if putting Having after OrderBy. This seems like a regression.
j
Oh interesting! That works!
m
Do you mind filing an issue? It is the code, not the docs that should be fixed.
j
Sure! Thanks all!
r
actually this is not the case: according to https://calcite.apache.org/docs/reference.html. ORDER BY must occur after HAVING/GROUPBY/WINDOW
so we should fix documentation