#12024·cube

type: number_agg fails schema validation unless multi_stage: true is set, but the measures reference lists it as a regular measure type

Author: ZmeiGorynychCreated Sep 28, 2026Updated Sep 28, 2026

Describe the bug

The measures reference lists number_agg in the type table as "Custom aggregate function | Custom aggregate not covered by other types (e.g., PERCENTILE_CONT). Tesseract only." Neither the table nor the warning below it says it needs multi_stage: true. A measure with type: number_agg and no multi_stage fails schema compilation, with Tesseract enabled or not, and the error doesn't mention multi_stage:

orders cube: "measures.max_amount_agg.type" must be one of [count, number, string, boolean, time, sum, avg, min, max, countDistinct, countDistinctApprox]. "measures.max_amount_agg.sql" is not allowed

CubeValidator only accepts numberAgg in multiStageMeasureType. The non-multi-stage branch of MeasuresSchema uses measureType, which doesn't include it. Tesseract, however, treats number_agg as a plain aggregated measure kind (measure_kinds/mod.rs, rendered pass-through at L209). Its test fixture measure_kind_tests.yaml declares type: numberAgg, sql: amount without multi_stage.

To Reproduce

  1. Data (DuckDB):
sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1, 'new', 100), (2, 'new', 200), (3, 'shipped', 300)
) AS t(id, status, amount);
  1. Use the schema below and run:
json
{"measures": ["orders.max_amount_agg"], "dimensions": ["orders.status"]}
  1. The query fails with the compile error above. The same happens with sql: amount instead of MAX({CUBE}.amount).

Expected behavior

Either number_agg is accepted on a regular measure, which the planner already supports, or the docs say it requires multi_stage: true and the validation error says so.

For comparison, type: number with the same sql returns new: 200, shipped: 300 on both planners. With multi_stage: true the measure compiles, but Tesseract then requires the sql to reference only members, and the referenced dimension to be in grain.include. For example, sql: "MAX({amount})" with grain: {include: [id, amount]} works.

Minimally reproducible Cube Schema

yaml
cubes:
  - name: orders
    sql_table: orders
    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true
      - name: status
        sql: status
        type: string
    measures:
      - name: max_amount_agg
        sql: "MAX({CUBE}.amount)"
        type: number_agg

Version:

1.7.46 (DuckDB driver), with CUBEJS_TESSERACT_SQL_PLANNER both true (default) and false.

Additional context

Related: #10798 (the same error message lists camelCase type names), #10799 (the SQL generated for number_agg measures that already have multi_stage: true), #10560.