MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / on_unique_window_agg

Method on_unique_window_agg

src/expr/src/relation.rs:3171–3191  ·  view source on GitHub ↗

`on_unique` for window aggregations

(
        window_frame: &WindowFrame,
        arg_expr: MirScalarExpr,
        input_type: &[ReprColumnType],
        return_type: ReprScalarType,
        wrapped_aggr: &AggregateFunc,
    )

Source from the content-addressed store, hash-verified

3169
3170 /// `on_unique` for window aggregations
3171 fn on_unique_window_agg(
3172 window_frame: &WindowFrame,
3173 arg_expr: MirScalarExpr,
3174 input_type: &[ReprColumnType],
3175 return_type: ReprScalarType,
3176 wrapped_aggr: &AggregateFunc,
3177 ) -> (MirScalarExpr, ColumnName) {
3178 // If the window frame includes the current (single) row, evaluate the wrapped aggregate on
3179 // that row. Otherwise, return the default value for the aggregate.
3180 let result_expr = if window_frame.includes_current_row() {
3181 AggregateExpr {
3182 func: wrapped_aggr.clone(),
3183 expr: arg_expr,
3184 distinct: false, // We have just one input element; DISTINCT doesn't matter.
3185 }
3186 .on_unique(input_type)
3187 } else {
3188 MirScalarExpr::literal_ok(wrapped_aggr.default(), return_type)
3189 };
3190 (result_expr, ColumnName::from("?window_agg?"))
3191 }
3192
3193 /// Returns whether the expression is COUNT(*) or not. Note that
3194 /// when we define the count builtin in sql::func, we convert

Callers

nothing calls this directly

Calls 4

includes_current_rowMethod · 0.80
on_uniqueMethod · 0.80
cloneMethod · 0.45
defaultMethod · 0.45

Tested by

no test coverage detected