Skip to content

Commit 33e7c5a

Browse files
authored
Merge pull request #1432 from johnedquinn/v1-conformance-agg-signatures
Updates AVG to return DECIMAL
2 parents 7289c9b + 3545703 commit 33e7c5a

File tree

2 files changed

+15
-14
lines changed
  • partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer
  • partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins

2 files changed

+15
-14
lines changed

partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,8 +3317,8 @@ class PlanTyperTestsPorted {
33173317
"min_b" to StaticType.INT4.asNullable(),
33183318
"max_a" to StaticType.INT4.asNullable(),
33193319
"max_b" to StaticType.INT4.asNullable(),
3320-
"avg_a" to StaticType.INT4.asNullable(),
3321-
"avg_b" to StaticType.INT4.asNullable(),
3320+
"avg_a" to StaticType.DECIMAL.asNullable(),
3321+
"avg_b" to StaticType.DECIMAL.asNullable(),
33223322
),
33233323
contentClosed = true,
33243324
constraints = setOf(

partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.partiql.spi.fn.FnExperimental
1010
import org.partiql.spi.fn.FnParameter
1111
import org.partiql.value.PartiQLValueExperimental
1212
import org.partiql.value.PartiQLValueType.ANY
13+
import org.partiql.value.PartiQLValueType.DECIMAL
1314
import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY
1415
import org.partiql.value.PartiQLValueType.FLOAT32
1516
import org.partiql.value.PartiQLValueType.FLOAT64
@@ -24,79 +25,79 @@ public object Agg_AVG__INT8__INT8 : Agg {
2425

2526
override val signature: AggSignature = AggSignature(
2627
name = "avg",
27-
returns = INT8,
28+
returns = DECIMAL,
2829
parameters = listOf(
2930
FnParameter("value", INT8),
3031
),
3132
isNullable = true,
3233
isDecomposable = true
3334
)
3435

35-
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT8)
36+
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL)
3637
}
3738

3839
@OptIn(PartiQLValueExperimental::class, FnExperimental::class)
3940
public object Agg_AVG__INT16__INT16 : Agg {
4041

4142
override val signature: AggSignature = AggSignature(
4243
name = "avg",
43-
returns = INT16,
44+
returns = DECIMAL,
4445
parameters = listOf(
4546
FnParameter("value", INT16),
4647
),
4748
isNullable = true,
4849
isDecomposable = true
4950
)
5051

51-
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT16)
52+
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL)
5253
}
5354

5455
@OptIn(PartiQLValueExperimental::class, FnExperimental::class)
5556
public object Agg_AVG__INT32__INT32 : Agg {
5657

5758
override val signature: AggSignature = AggSignature(
5859
name = "avg",
59-
returns = INT32,
60+
returns = DECIMAL,
6061
parameters = listOf(
6162
FnParameter("value", INT32),
6263
),
6364
isNullable = true,
6465
isDecomposable = true
6566
)
6667

67-
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT32)
68+
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL)
6869
}
6970

7071
@OptIn(PartiQLValueExperimental::class, FnExperimental::class)
7172
public object Agg_AVG__INT64__INT64 : Agg {
7273

7374
override val signature: AggSignature = AggSignature(
7475
name = "avg",
75-
returns = INT64,
76+
returns = DECIMAL,
7677
parameters = listOf(
7778
FnParameter("value", INT64),
7879
),
7980
isNullable = true,
8081
isDecomposable = true
8182
)
8283

83-
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT64)
84+
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL)
8485
}
8586

8687
@OptIn(PartiQLValueExperimental::class, FnExperimental::class)
8788
public object Agg_AVG__INT__INT : Agg {
8889

8990
override val signature: AggSignature = AggSignature(
9091
name = "avg",
91-
returns = INT,
92+
returns = DECIMAL_ARBITRARY,
9293
parameters = listOf(
9394
FnParameter("value", INT),
9495
),
9596
isNullable = true,
9697
isDecomposable = true
9798
)
9899

99-
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(INT)
100+
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL_ARBITRARY)
100101
}
101102

102103
@OptIn(PartiQLValueExperimental::class, FnExperimental::class)
@@ -152,13 +153,13 @@ public object Agg_AVG__ANY__ANY : Agg {
152153

153154
override val signature: AggSignature = AggSignature(
154155
name = "avg",
155-
returns = ANY,
156+
returns = DECIMAL_ARBITRARY,
156157
parameters = listOf(
157158
FnParameter("value", ANY),
158159
),
159160
isNullable = true,
160161
isDecomposable = true
161162
)
162163

163-
override fun accumulator(): Agg.Accumulator = AccumulatorAvg()
164+
override fun accumulator(): Agg.Accumulator = AccumulatorAvg(DECIMAL_ARBITRARY)
164165
}

0 commit comments

Comments
 (0)