A SQL HAVING clause is essentially a filter that is applied on the results of an aggregation. Depending on how calcite exposes this, it may be relatively easy to hook this up to DHC table operation; ideally, calcite would expose a variable into the aggergation regardless of whether it shows up in the end results or not. In that way, it would be trivial to just apply a DHC where filter after the aggregation and then drop the column if it's not in the output. If calcite does not expose the condition into the aggregation, we may want to introspect the query and make it so.
Here's an example where having clause can be computed from the results of the basic aggregation:
SELECT
group, COUNT(id)
FROM
my_table
GROUP BY
group
HAVING COUNT(id) > 5
Here's an example where an additional (simple) aggregation needs to be performed:
SELECT
group, COUNT(id)
FROM
my_table
GROUP BY
group
HAVING MAX(id) < 42
Here's an example of a more complex having aggregation:
SELECT
group, COUNT(id)
FROM
my_table
GROUP BY
group
HAVING MAX(id) - MIN(id) > 13
It may be that only relatively simple having queries can be easily translated; TBD.
Part of #3473
A SQL HAVING clause is essentially a filter that is applied on the results of an aggregation. Depending on how calcite exposes this, it may be relatively easy to hook this up to DHC table operation; ideally, calcite would expose a variable into the aggergation regardless of whether it shows up in the end results or not. In that way, it would be trivial to just apply a DHC where filter after the aggregation and then drop the column if it's not in the output. If calcite does not expose the condition into the aggregation, we may want to introspect the query and make it so.
Here's an example where having clause can be computed from the results of the basic aggregation:
Here's an example where an additional (simple) aggregation needs to be performed:
Here's an example of a more complex having aggregation:
It may be that only relatively simple having queries can be easily translated; TBD.
Part of #3473