Skip to content

Commit 06e0778

Browse files
committed
Fix vam bug affecting count by string with where clause
Vam does not honor the where clause in "count() where <expr> by <string_valued_expr>". Fix by using runtime/vam/op/summarize.countbyString only when no where clause is present.
1 parent 8d1c21a commit 06e0778

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

runtime/vam/op/summarize/summarize.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ func (s *Summarize) consume(keys []vector.Any, vals []vector.Any) {
104104

105105
func (s *Summarize) newAggTable(keyTypes []super.Type) aggTable {
106106
// Check if we can us an optimized table, else go slow path.
107-
if s.isCountByString(keyTypes) {
107+
if s.isCountByString(keyTypes) && len(s.aggs) == 1 && s.aggs[0].Where == nil {
108+
// countByString.update does not handle nulls in its vals param.
108109
return newCountByString(s.builder, s.partialsIn)
109110
}
110111
return &superTable{

runtime/vam/op/ztests/agg-count-by-string.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ script: |
1010
super dev vector query -z 'count() by x' t.csup
1111
super dev vector query -z 'count() by y' t.csup | super -z -c 'sort y' -
1212
super dev vector query -z 'count() by z' t.csup | super -z -c 'z=="257"' -
13+
super dev vector query -z 'count() where y=="1" by z' t.csup | super -z -c 'z=="257"' -
1314
1415
outputs:
1516
- name: stdout
@@ -18,3 +19,4 @@ outputs:
1819
{y:"1",count:257(uint64)}
1920
{y:"2",count:257(uint64)}
2021
{z:"257",count:2(uint64)}
22+
{z:"257",count:1(uint64)}

0 commit comments

Comments
 (0)