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

Pagination for indexes does not work #100

Open
iisulop opened this issue Mar 13, 2020 · 1 comment
Open

Pagination for indexes does not work #100

iisulop opened this issue Mar 13, 2020 · 1 comment

Comments

@iisulop
Copy link

iisulop commented Mar 13, 2020

It seems pagination does not work properly for indexes. When doing scans on tables they do work. The problem appears when trying to paginate using last and again or recursive.

from faker import Faker
import uuid as uuid
from dynamorm import (
    DynaModel,
    GlobalIndex,
    ProjectAll,
)
from marshmallow import fields

faker = Faker()

class BigProblem(DynaModel):
    class Table:
        name = 'example_big_query_problem_table_1'
        hash_key = 'uuid'

    class TypeIndex(GlobalIndex):
        """Index for quickly accessing individual tags"""
        name = 'type_index'
        hash_key = 'type'
        projection = ProjectAll()

    class Schema:
        uuid = fields.Str(missing=lambda: str(uuid.uuid4()))
        type = fields.Str(missing=lambda: 'data')
        data = fields.List(fields.Str())


BigProblem.Table.delete()
if not BigProblem.Table.exists:
    BigProblem.Table.create(wait=True)
    for _ in range(1000):
        BigProblem(data=[faker.name() for _ in range(100)]).save()


type_it = BigProblem.TypeIndex.query(type='data')
types = list(type_it)
while type_it.last is not None:
    type_it.again()
    print(len(types))
    types.extend(type_it)
print(len(types))

Expected types to include all the rows in the table.

Result:

File "minimal_query_problem.py", line 41, in
types.extend(type_it)
...
File ".venv/lib/python3.7/site-packages/botocore/client.py", line 586, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Query operation: KeyConditionExpressions must only contain one condition per key

@iisulop
Copy link
Author

iisulop commented Mar 13, 2020

Sorry. I had to write the description in a bit of a hurry. Ask for more information if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant