Skip to content

Commit

Permalink
cast min max values correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Sep 27, 2024
1 parent 63f062c commit db85fa3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
6 changes: 2 additions & 4 deletions internal/planner/max.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 2 additions & 4 deletions internal/planner/min.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion tests/integration/query/simple/with_group_max_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func TestQuerySimple_WithGroupByStringWithoutRenderedGroupAndChildEmptyFloatMax_
},
{
"Name": "Alice",
"_max": -math.MaxFloat64,
"_max": float64(-math.MaxFloat64),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/query/simple/with_group_min_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func TestQuerySimple_WithGroupByStringWithoutRenderedGroupAndChildEmptyFloatMin_
},
{
"Name": "Alice",
"_min": math.MaxFloat64,
"_min": float64(math.MaxFloat64),
},
},
},
Expand Down

0 comments on commit db85fa3

Please sign in to comment.