Kaizen
Browse modulesInsightsinsights/sharedFunctions

Function: isGroupedDefinition()

function isGroupedDefinition(definition: {
  aggregations?: {
     alias: string;
     field?: string;
     fn: "min" | "max" | "count" | "avg" | "sum";
  }[];
  columns: string[];
  filter?: FilterNode;
  groupBy?: {
     bucket?: "year" | "month" | "day" | "week" | "quarter";
     field: string;
  }[];
  schemaVersion: 1;
  sort: {
     by: string;
     direction: "asc" | "desc";
  }[];
  subject: string;
  timezone: string;
  totals?: boolean;
}): boolean;

Defined in: shared/insights/validate-definition.ts:215

A definition with any groupBy or any aggregations compiles as a grouped run — the single groupedness predicate the validator and the compiler share.

Parameters

ParameterTypeDescription
definition{ aggregations?: { alias: string; field?: string; fn: "min" | "max" | "count" | "avg" | "sum"; }[]; columns: string[]; filter?: FilterNode; groupBy?: { bucket?: "year" | "month" | "day" | "week" | "quarter"; field: string; }[]; schemaVersion: 1; sort: { by: string; direction: "asc" | "desc"; }[]; subject: string; timezone: string; totals?: boolean; }-
definition.aggregations?{ alias: string; field?: string; fn: "min" | "max" | "count" | "avg" | "sum"; }[]-
definition.columnsstring[]The SELECT list — and the ONLY source of output columns, for grouped runs as much as detail runs: the compiler derives its projection from columns alone and never from groupBy/aggregations. So an empty columns has no compilable projection at all (not merely a semantically odd one), which makes it a STRUCTURAL failure and puts the check here rather than in validateDefinition. Keeping it in the schema also means every surface that parses a definition — run input, saved-report create/update, normalizeSavedReportDefinition on read, canned reports in the registry — fails closed without having to remember a second validation pass.
definition.filter?FilterNode-
definition.groupBy?{ bucket?: "year" | "month" | "day" | "week" | "quarter"; field: string; }[]-
definition.schemaVersion1-
definition.sort{ by: string; direction: "asc" | "desc"; }[]-
definition.subjectstring-
definition.timezonestring-
definition.totals?boolean-

Returns

boolean

On this page