Styxis
Company
Knowledge

Inspect execution when aggregation CSE changes a scalar into a list

Expression reuse can change an aggregate’s role and dtype. Admit the plan and the executed result separately.

The meaning of one value per group

Verify aggregate dtype and element role from actual execution before treating one scalar and a per-row list as the same metric. They can feed different results to a consumer’s next sum or mean. A plan schema is a separate artifact from the collected output. A table of externally extracted planned and executed dtypes defines the boundary connected to Truthound. [1, 2, 3]

The follow-up narrows the CSE path

Polars #28653 reports CSE of repeated literal expressions in group aggregation producing List(Float64) instead of the planned Float64. A contributor initially could not reproduce it, then corrected that after checking the environment. The investigation is not evidence of a verified fix in every environment. [1]

Read dtypes from actual collect output

Record requested expressions and planned and actual dtypes per group. Hold list-valued outputs where the approved contract requires a scalar and compare a CSE control. Read dtypes from actual collect output, retaining empty-group and expression-reuse conditions. [1, 3]

Different roles for 1.5 and [1.5,1.5]

The illustrative expression abs(-1.5) returns one scalar per group, so required dtype is Float64. Actual Float64 passes; List(Float64) fails. A list [1.5,1.5] does not become the same scalar 1.5 without a separate aggregate definition. [1, 3]

Signature comparison is not value validation

ColumnPairValidator in Truthound Python SDK 3.3.2 compares actual_aggregate_dtype extracted by the operator with approved_aggregate_dtype signatures. Operators define nested-type normalization and value checks. Core does not inspect optimizer CSE or nested schemas automatically; dtype agreement does not establish correct aggregate values. [1, 2, 3]

Check values in the CSE control too

Compare a verified CSE-disabled control or a materialized-expression path with its cost, then check values and dtypes again. Existing regressions for the same expression and engine reduce another audit’s benefit. Do not silently collapse lists to force the promised schema. [1, 3]

Application conditions

Retain dtypes from actual collect output, requested expressions, empty-group and reuse conditions, and the approved scalar signature.

Alternatives

Compare values, dtypes, and costs for verified CSE-disabled or materialized paths.

Limitations

  • Dtype agreement does not establish aggregate values or automatically inspect optimizer CSE.

Evidence

Event checked
Subject checked
Modified