From db85fa3138bb018b967ea92368cb77452c45f41f Mon Sep 17 00:00:00 2001 From: Keenan Nemetz Date: Fri, 27 Sep 2024 10:05:34 -0700 Subject: [PATCH] cast min max values correctly --- internal/planner/max.go | 6 ++---- internal/planner/min.go | 6 ++---- tests/integration/query/simple/with_group_max_test.go | 2 +- tests/integration/query/simple/with_group_min_test.go | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/internal/planner/max.go b/internal/planner/max.go index c9254550e1..f16ad22ed5 100644 --- a/internal/planner/max.go +++ b/internal/planner/max.go @@ -221,13 +221,11 @@ func (n *maxNode) Next() (bool, error) { max = math.Max(max, collectionMax) } - var typedMax any if n.isFloat { - typedMax = max + n.currentValue.Fields[n.virtualFieldIndex] = float64(max) } else { - typedMax = int64(max) + n.currentValue.Fields[n.virtualFieldIndex] = int64(max) } - n.currentValue.Fields[n.virtualFieldIndex] = typedMax return true, nil } diff --git a/internal/planner/min.go b/internal/planner/min.go index ceceb65623..201e6ebc7b 100644 --- a/internal/planner/min.go +++ b/internal/planner/min.go @@ -221,13 +221,11 @@ func (n *minNode) Next() (bool, error) { min = math.Min(min, collectionMin) } - var typedMin any if n.isFloat { - typedMin = min + n.currentValue.Fields[n.virtualFieldIndex] = float64(min) } else { - typedMin = int64(min) + n.currentValue.Fields[n.virtualFieldIndex] = int64(min) } - n.currentValue.Fields[n.virtualFieldIndex] = typedMin return true, nil } diff --git a/tests/integration/query/simple/with_group_max_test.go b/tests/integration/query/simple/with_group_max_test.go index 6c093c652d..bec41dfa80 100644 --- a/tests/integration/query/simple/with_group_max_test.go +++ b/tests/integration/query/simple/with_group_max_test.go @@ -291,7 +291,7 @@ func TestQuerySimple_WithGroupByStringWithoutRenderedGroupAndChildEmptyFloatMax_ }, { "Name": "Alice", - "_max": -math.MaxFloat64, + "_max": float64(-math.MaxFloat64), }, }, }, diff --git a/tests/integration/query/simple/with_group_min_test.go b/tests/integration/query/simple/with_group_min_test.go index c7fa81d38c..92477b5bc2 100644 --- a/tests/integration/query/simple/with_group_min_test.go +++ b/tests/integration/query/simple/with_group_min_test.go @@ -291,7 +291,7 @@ func TestQuerySimple_WithGroupByStringWithoutRenderedGroupAndChildEmptyFloatMin_ }, { "Name": "Alice", - "_min": math.MaxFloat64, + "_min": float64(math.MaxFloat64), }, }, },