Skip to content

Commit

Permalink
zach comments
Browse files Browse the repository at this point in the history
  • Loading branch information
max-hoffman committed Aug 8, 2024
1 parent ff89161 commit 4fc3498
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 3 additions & 5 deletions go/libraries/doltcore/sqle/kvexec/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,14 @@ func (b Builder) Build(ctx *sql.Context, n sql.Node, r sql.Row) (sql.RowIter, er
}
}
case *plan.GroupBy:
// no grouping
// only COUNT expression
// table or ita as child
// simple count expression
// no filter
if len(n.GroupByExprs) == 0 && len(n.SelectedExprs) == 1 {
if cnt, ok := n.SelectedExprs[0].(*aggregation.Count); ok {
if _, srcIter, _, srcSchema, _, srcFilter, err := getSourceKv(ctx, n.Child, true); err == nil && srcSchema != nil && srcFilter == nil {
iter, ok, err := newCountAggregationKvIter(srcIter, srcSchema, cnt.Child)
if ok && err == nil {
// (1) no grouping expressions (returns one row)
// (2) only one COUNT expression with a literal or field reference
// (3) table or ita as child (no filters)
return iter, nil
}
}
Expand Down
2 changes: 2 additions & 0 deletions go/libraries/doltcore/sqle/kvexec/count_agg.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func (l *countAggKvIter) Next(ctx *sql.Context) (sql.Row, error) {
k, v, err := l.srcIter.Next(ctx)
if err == io.EOF {
break
} else if err != nil {
return nil, err
}
if l.nullable {
if l.isKeyRef && k.FieldIsNull(l.idx) ||
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/kvexec/count_agg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestCountAgg(t *testing.T) {
doRowexec: true,
},
{
name: "reject complex count expressi on",
name: "reject complex count expression",
setup: []string{
"create table xy (x int primary key, y int, key y_idx(y))",
},
Expand Down

0 comments on commit 4fc3498

Please sign in to comment.