diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt index 78f25c0480..090a444efb 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt @@ -3317,8 +3317,8 @@ class PlanTyperTestsPorted { "min_b" to StaticType.INT4.asNullable(), "max_a" to StaticType.INT4.asNullable(), "max_b" to StaticType.INT4.asNullable(), - "avg_a" to StaticType.INT4.asNullable(), - "avg_b" to StaticType.INT4.asNullable(), + "avg_a" to StaticType.DECIMAL.asNullable(), + "avg_b" to StaticType.DECIMAL.asNullable(), ), contentClosed = true, constraints = setOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt index cf110ab6a3..1287a7f011 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt @@ -10,6 +10,7 @@ import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.ANY +import org.partiql.value.PartiQLValueType.DECIMAL import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY import org.partiql.value.PartiQLValueType.FLOAT32 import org.partiql.value.PartiQLValueType.FLOAT64 @@ -24,7 +25,7 @@ public object Agg_AVG__INT8__INT8 : Agg { override val signature: AggSignature = AggSignature( name = "avg", - returns = INT8, + returns = DECIMAL, parameters = listOf( FnParameter("value", INT8), ), @@ -32,7 +33,7 @@ public object Agg_AVG__INT8__INT8 : Agg { isDecomposable = true ) - override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT8) + override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL) } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) @@ -40,7 +41,7 @@ public object Agg_AVG__INT16__INT16 : Agg { override val signature: AggSignature = AggSignature( name = "avg", - returns = INT16, + returns = DECIMAL, parameters = listOf( FnParameter("value", INT16), ), @@ -48,7 +49,7 @@ public object Agg_AVG__INT16__INT16 : Agg { isDecomposable = true ) - override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT16) + override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL) } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) @@ -56,7 +57,7 @@ public object Agg_AVG__INT32__INT32 : Agg { override val signature: AggSignature = AggSignature( name = "avg", - returns = INT32, + returns = DECIMAL, parameters = listOf( FnParameter("value", INT32), ), @@ -64,7 +65,7 @@ public object Agg_AVG__INT32__INT32 : Agg { isDecomposable = true ) - override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT32) + override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL) } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) @@ -72,7 +73,7 @@ public object Agg_AVG__INT64__INT64 : Agg { override val signature: AggSignature = AggSignature( name = "avg", - returns = INT64, + returns = DECIMAL, parameters = listOf( FnParameter("value", INT64), ), @@ -80,7 +81,7 @@ public object Agg_AVG__INT64__INT64 : Agg { isDecomposable = true ) - override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT64) + override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL) } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) @@ -88,7 +89,7 @@ public object Agg_AVG__INT__INT : Agg { override val signature: AggSignature = AggSignature( name = "avg", - returns = INT, + returns = DECIMAL_ARBITRARY, parameters = listOf( FnParameter("value", INT), ), @@ -96,7 +97,7 @@ public object Agg_AVG__INT__INT : Agg { isDecomposable = true ) - override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT) + override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL_ARBITRARY) } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) @@ -152,7 +153,7 @@ public object Agg_AVG__ANY__ANY : Agg { override val signature: AggSignature = AggSignature( name = "avg", - returns = ANY, + returns = DECIMAL_ARBITRARY, parameters = listOf( FnParameter("value", ANY), ), @@ -160,5 +161,5 @@ public object Agg_AVG__ANY__ANY : Agg { isDecomposable = true ) - override fun accumulator(): Agg.Accumulator = AccumulatorAvg() + override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL_ARBITRARY) }