Skip to content

Commit

Permalink
fix: avoid random rounding problems in stddev function
Browse files Browse the repository at this point in the history
  • Loading branch information
bobeal committed Jul 19, 2024
1 parent 210cb71 commit d191ba5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private fun sqlAggregateForJsonNumber(aggregate: TemporalQuery.Aggregate): Strin
TemporalQuery.Aggregate.AVG -> "avg(measured_value)"
TemporalQuery.Aggregate.MIN -> "min(measured_value)"
TemporalQuery.Aggregate.MAX -> "max(measured_value)"
TemporalQuery.Aggregate.STDDEV -> "stddev_samp(measured_value)"
TemporalQuery.Aggregate.STDDEV -> "round(stddev_samp(measured_value)::numeric,10)"
TemporalQuery.Aggregate.SUMSQ -> "sum(power(measured_value,2))"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AggregatedQueryServiceTests : WithTimescaleContainer, WithKafkaContainer {
"avg, 5.5",
"min, 1.0",
"max, 10.0",
"stddev, 3.0276503540974917",
"stddev, 3.0276503541",
"sumsq, 385.0"
)
fun `it should correctly aggregate on JSON Number values`(aggrMethod: String, expectedValue: String) = runTest {
Expand Down

0 comments on commit d191ba5

Please sign in to comment.