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

[BUG] Potential bug with aggregation pipeline #852

Open
creyD opened this issue Jul 19, 2023 · 0 comments
Open

[BUG] Potential bug with aggregation pipeline #852

creyD opened this issue Jul 19, 2023 · 0 comments

Comments

@creyD
Copy link

creyD commented Jul 19, 2023

I am using the aggregation pipeline below which results in success with pymongo itself. With mongomock there is the error message TypeError: int() argument must be a string, a bytes-like object or a real number, not 'datetime.datetime'. Is this a limitation of mongomock encountered here?

[
    {
        "$match": {
            "$and": [
                {"topic_name": "door"},
                {"internal_id": "7XXXXX"},
				{"payload.ts": {"$gte": datetime.datetime(2023, 4, 11, 0, 0), "$lte": datetime.datetime(2023, 4, 13, 0, 0)}},
            ]
        }
    },
    {"$sort": {"payload.ts": -1}},
    {
        "$project": {
            "timestamp": {"$dateToString": {"date": "$payload.ts", "format": "%m-%d-%Y"}},
            "value": "$payload.val",
            "timestampOriginal": {"$toLong": "$payload.ts"},
        }
    },
    {
        "$group": {
            "_id": "$timestamp",
            "open": {"$first": "$value"},
            "close": {"$last": "$value"},
            "avg": {"$avg": "$value"},
            "high": {"$max": "$value"},
            "low": {"$min": "$value"},
            "sum": {"$sum": "$value"},
            "count": {"$sum": 1},
            "timestamp": {"$first": "$timestampOriginal"},
        }
    },
    {"$sort": {"timestamp": 1}},
]

The data is very similar, see screenshot below where I printed parts of both datasets.

datasets look similar

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