Skip to content

feat(sql-utilities): support multiple SELECT projections with single aggregate#362

Merged
milindsrivastava1997 merged 2 commits into
mainfrom
361-featsql-utilities-support-multiple-select-projections-with-a-single-aggregate-function
May 24, 2026
Merged

feat(sql-utilities): support multiple SELECT projections with single aggregate#362
milindsrivastava1997 merged 2 commits into
mainfrom
361-featsql-utilities-support-multiple-select-projections-with-a-single-aggregate-function

Conversation

@akanksha-akkihal

Copy link
Copy Markdown
Collaborator

Summary

Relax the projection parser to support standard grouped-aggregate SQL forms such as:

SELECT g1, g2, agg(v)
FROM t
GROUP BY g1, g2

Previously, the parser required projection.len() == 1, causing these queries to fall through to destination=none_unsupported.

Changes

  • Walk the full projection list instead of requiring a single projection item

  • Allow:

    • exactly one aggregate function
    • any number of plain column references
  • Require every non-aggregate identifier in SELECT to also appear in GROUP BY, matching standard SQL semantics

This prevents cases like:

SELECT srcip, SUM(v)
FROM t
GROUP BY proto

from being silently interpreted as if srcip were never requested.

Still Unsupported

The parser continues to reject:

  • multiple aggregates
  • computed expressions
  • literals
  • wildcards (*)

The structural pattern model still supports only a single aggregate statistic.

Tests Added

Added 8 parser tests covering:

  • group columns followed by aggregate

  • aggregate-first ordering

  • ClickHouse parametric quantile in multi-projection form

  • structural equivalence between single- and multi-projection queries

  • SELECT subset of GROUP BY

  • rejection of:

    • non-GROUP BY identifiers
    • multiple aggregates
    • arbitrary expressions

@milindsrivastava1997 milindsrivastava1997 merged commit d7fced2 into main May 24, 2026
7 checks passed
@milindsrivastava1997 milindsrivastava1997 deleted the 361-featsql-utilities-support-multiple-select-projections-with-a-single-aggregate-function branch May 24, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sql-utilities): Support multiple SELECT projections alongside a single aggregate function

2 participants