def _read_query_chunked()

in awswrangler/dynamodb/_read.py [0:0]


def _read_query_chunked(table_name: str, dynamodb_client: "DynamoDBClient", **kwargs: Any) -> Iterator[_ItemsListType]:
    next_token: str | None = "init_token"  # Dummy token
    total_items = 0

    # Handle pagination
    while next_token:
        response = dynamodb_client.query(TableName=table_name, **kwargs)
        items = response.get("Items", [])
        total_items += len(items)
        yield [_deserialize_item(item) for item in items]

        if ("Limit" in kwargs) and (total_items >= kwargs["Limit"]):
            break

        next_token = response.get("LastEvaluatedKey", None)
        if next_token:
            kwargs["ExclusiveStartKey"] = next_token