Skip to content

feat(sql-utilities, query-engine): add SQL ORDER BY and LIMIT support for grouped aggregate queries. #363

@akanksha-akkihal

Description

@akanksha-akkihal

ASAPQuery currently rejects grouped aggregate queries that include ORDER BY or LIMIT, even when the aggregation itself is already supported and precomputed.

For example, the following query falls through with destination=none_unsupported:
SELECT proto, srcip, dstip, quantile(0.99)(pkt_len) AS p99_pkt_len FROM netflow_table WHERE time BETWEEN DATEADD(s, -11, NOW()) AND DATEADD(s, -10, NOW()) GROUP BY proto, srcip, dstip ORDER BY p99_pkt_len DESC LIMIT 10
This blocks common analytics patterns such as sorting aggregate results by percentile/sum/count metrics.

Success Criteria

  • Queries with supported grouped aggregations continue to match the existing precomputed aggregation path when ORDER BY and/or LIMIT are present.
  • ORDER BY on the aggregate alias or aggregate expression is accepted.
  • LIMIT is accepted.
  • Existing aggregation matching and execution behavior remains unchanged aside from applying ordering/limit to the result set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions