From 9c08ae778b739f48167669b7782e074b82422048 Mon Sep 17 00:00:00 2001 From: eastfisher Date: Tue, 19 Nov 2019 11:06:10 +0800 Subject: [PATCH] fix: return 0 when no result in sum() --- proxy/plan/merge_result.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/proxy/plan/merge_result.go b/proxy/plan/merge_result.go index 98300331..6f6a2105 100644 --- a/proxy/plan/merge_result.go +++ b/proxy/plan/merge_result.go @@ -173,6 +173,13 @@ func (a *AggregateFuncSumMerger) MergeTo(from, to ResultRow) error { return fmt.Errorf("field index out of bound: %d", a.fieldIndex) } + fromValueI := from.GetValue(idx) + + // nil对应NULL, NULL不参与比较 + if fromValueI == nil { + return nil + } + switch to.GetValue(idx).(type) { case int64: return a.sumToInt64(from, to)