Skip to content

Fix source inference for source-less aggregate measures - #354

Open
sahniaditya007 wants to merge 1 commit into
Kaelio:mainfrom
sahniaditya007:fix/sl-sourceless-aggregate-inference
Open

Fix source inference for source-less aggregate measures#354
sahniaditya007 wants to merge 1 commit into
Kaelio:mainfrom
sahniaditya007:fix/sl-sourceless-aggregate-inference

Conversation

@sahniaditya007

Copy link
Copy Markdown

Fixes #336

Summary

This PR adds source inference for source-less aggregate expressions in the semantic layer.

Previously, aggregate expressions without an explicit source.column reference (for example count(*), count(1), and sum(amount)) were rejected because no source could be inferred.

This change infers the source when the query already determines a single unambiguous source through its dimensions and/or other measures. Queries that remain ambiguous or have no inferable source continue to raise an error with improved guidance.

Changes

  • Infer the source for source-less aggregate expressions when exactly one source can be determined.
  • Preserve existing rejection behavior for ambiguous and zero-source queries.
  • Improve error messages by:
    • listing candidate sources
    • suggesting count(source.pk) alternatives
  • Add unit tests covering:
    • count(*)
    • count(1)
    • bare-column aggregates (sum(amount))
    • dimension-only inference
    • measure-only inference
    • mixed queries
    • dictionary measure definitions
    • ambiguous multi-source queries
    • zero-source queries

Testing

  • Ran the semantic layer test suite.
  • Added unit tests covering both successful inference and expected failure scenarios.

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@sahniaditya007 is attempting to deploy a commit to the Kaelio Team on Vercel.

A member of the Team first needs to authorize it.

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.

sl_query rejects count(*) and bare-column aggregates ("does not reference any source")

1 participant