Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colexec: fix external aggregator fallback and bool agg functions reset #59055

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions pkg/sql/colexec/colexecagg/bool_and_or_agg_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ type bool_OP_TYPE_AGGKINDAgg struct {
// {{else}}
hashAggregateFuncBase
// {{end}}
col []bool
sawNonNull bool
curAgg bool
col []bool
curAgg bool
// foundNonNullForCurrentGroup tracks if we have seen any non-null values
// for the group that is currently being aggregated.
foundNonNullForCurrentGroup bool
}

var _ AggregateFunc = &bool_OP_TYPE_AGGKINDAgg{}
Expand Down Expand Up @@ -134,7 +136,7 @@ func (a *bool_OP_TYPE_AGGKINDAgg) Flush(outputIdx int) {
outputIdx = a.curIdx
a.curIdx++
// {{end}}
if !a.sawNonNull {
if !a.foundNonNullForCurrentGroup {
a.nulls.SetNull(outputIdx)
} else {
a.col[outputIdx] = a.curAgg
Expand All @@ -151,6 +153,7 @@ func (a *bool_OP_TYPE_AGGKINDAgg) Reset() {
// _DEFAULT_VAL is false.
// */}}
a.curAgg = _DEFAULT_VAL
a.foundNonNullForCurrentGroup = false
}

type bool_OP_TYPE_AGGKINDAggAlloc struct {
Expand Down Expand Up @@ -190,7 +193,7 @@ func _ACCUMULATE_BOOLEAN(
// {{end}}
if groups[i] {
if !a.isFirstGroup {
if !a.sawNonNull {
if !a.foundNonNullForCurrentGroup {
a.nulls.SetNull(a.curIdx)
} else {
a.col[a.curIdx] = a.curAgg
Expand All @@ -199,7 +202,7 @@ func _ACCUMULATE_BOOLEAN(
// {{with .Global}}
a.curAgg = _DEFAULT_VAL
// {{end}}
a.sawNonNull = false
a.foundNonNullForCurrentGroup = false
}
a.isFirstGroup = false
}
Expand All @@ -218,7 +221,7 @@ func _ACCUMULATE_BOOLEAN(
// {{with .Global}}
_ASSIGN_BOOL_OP(a.curAgg, a.curAgg, col[i])
// {{end}}
a.sawNonNull = true
a.foundNonNullForCurrentGroup = true
}

// {{end}}
Expand Down
30 changes: 18 additions & 12 deletions pkg/sql/colexec/colexecagg/hash_bool_and_or_agg.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading