Skip to content

Commit 0d6f17f

Browse files
quintonparkerQ
andauthored
Proposed fix. Allow empty group_by([], reducer) ie. GROUPBY 0 (#68)
Co-authored-by: Q <quintonparker@gmail.com>
1 parent f8ec328 commit 0d6f17f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

redisearch/aggregation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class Group(object):
8686
This object automatically created in the `AggregateRequest.group_by()`
8787
"""
8888
def __init__(self, fields, reducers):
89-
if not fields:
90-
raise ValueError('need at least one field')
9189
if not reducers:
9290
raise ValueError('Need at least one reducer')
9391

test/test_builder.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ def testGroup(self):
4040
# Check the group class on its own
4141
self.assertRaises(ValueError, a.Group, [], [])
4242
self.assertRaises(ValueError, a.Group, ['foo'], [])
43-
self.assertRaises(ValueError, a.Group, [], r.count())
43+
44+
# Zero fields, single reducer
45+
g = a.Group([], r.count())
46+
ret = g.build_args()
47+
self.assertEqual(['GROUPBY', '0', 'REDUCE', 'COUNT', '0'], ret)
4448

4549
# Single field, single reducer
4650
g = a.Group('foo', r.count())

0 commit comments

Comments
 (0)