Skip to content

Commit

Permalink
Add test for LIMIT offset num (#1672)
Browse files Browse the repository at this point in the history
* test

* updated test for coordinator
  • Loading branch information
ashtul committed Nov 23, 2020
1 parent a2c5ac2 commit 685929a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/pytests/test_aggregate.py
Expand Up @@ -518,3 +518,50 @@ def testStartsWith(env):
env.assertEqual(toSortedFlatList(res), toSortedFlatList([1L, ['t', 'aa', 'prefix', '1'], \
['t', 'aaa', 'prefix', '1'], \
['t', 'ab', 'prefix', '0']]))

def testLimitIssue(env):
#ticket 66895
conn = getConnectionByEnv(env)
conn.execute_command('ft.create', 'idx', 'SCHEMA', 'PrimaryKey', 'TEXT', 'SORTABLE',
'CreatedDateTimeUTC', 'NUMERIC', 'SORTABLE')
conn.execute_command('HSET', 'doc1', 'PrimaryKey', '9::362330', 'CreatedDateTimeUTC', '637387878524969984')
conn.execute_command('HSET', 'doc2', 'PrimaryKey', '9::362329', 'CreatedDateTimeUTC', '637387875859270016')
conn.execute_command('HSET', 'doc3', 'PrimaryKey', '9::362326', 'CreatedDateTimeUTC', '637386176589869952')
conn.execute_command('HSET', 'doc4', 'PrimaryKey', '9::362311', 'CreatedDateTimeUTC', '637383865971600000')
conn.execute_command('HSET', 'doc5', 'PrimaryKey', '9::362310', 'CreatedDateTimeUTC', '637383864050669952')
conn.execute_command('HSET', 'doc6', 'PrimaryKey', '9::362309', 'CreatedDateTimeUTC', '637242254008029952')
conn.execute_command('HSET', 'doc7', 'PrimaryKey', '9::362308', 'CreatedDateTimeUTC', '637242253551670016')
conn.execute_command('HSET', 'doc8', 'PrimaryKey', '9::362306', 'CreatedDateTimeUTC', '637166988081200000')

_res = [8L,
['PrimaryKey', '9::362330', 'CreatedDateTimeUTC', '637387878524969984'],
['PrimaryKey', '9::362329', 'CreatedDateTimeUTC', '637387875859270016'],
['PrimaryKey', '9::362326', 'CreatedDateTimeUTC', '637386176589869952'],
['PrimaryKey', '9::362311', 'CreatedDateTimeUTC', '637383865971600000'],
['PrimaryKey', '9::362310', 'CreatedDateTimeUTC', '637383864050669952'],
['PrimaryKey', '9::362309', 'CreatedDateTimeUTC', '637242254008029952'],
['PrimaryKey', '9::362308', 'CreatedDateTimeUTC', '637242253551670016'],
['PrimaryKey', '9::362306', 'CreatedDateTimeUTC', '637166988081200000']]

actual_res = conn.execute_command('FT.AGGREGATE', 'idx', '*',
'APPLY', '@PrimaryKey', 'AS', 'PrimaryKey',
'SORTBY', '2', '@CreatedDateTimeUTC', 'DESC', 'LIMIT', '0', '8')
env.assertEqual(actual_res, _res)

res = [_res[0]] + _res[1:3]
actual_res = conn.execute_command('FT.AGGREGATE', 'idx', '*',
'APPLY', '@PrimaryKey', 'AS', 'PrimaryKey',
'SORTBY', '2', '@CreatedDateTimeUTC', 'DESC', 'LIMIT', '0', '2')
env.assertEqual(actual_res, res)

res = [_res[0]] + _res[2:4]
actual_res = conn.execute_command('FT.AGGREGATE', 'idx', '*',
'APPLY', '@PrimaryKey', 'AS', 'PrimaryKey',
'SORTBY', '2', '@CreatedDateTimeUTC', 'DESC', 'LIMIT', '1', '2')
env.assertEqual(actual_res, res)

res = [_res[0]] + _res[3:5]
actual_res = conn.execute_command('FT.AGGREGATE', 'idx', '*',
'APPLY', '@PrimaryKey', 'AS', 'PrimaryKey',
'SORTBY', '2', '@CreatedDateTimeUTC', 'DESC', 'LIMIT', '2', '2')
env.assertEqual(actual_res, res)

0 comments on commit 685929a

Please sign in to comment.