MongoDB query return no values
diegotiendanube opened this issue · 1 comments
I'm trying to run a query in MongoDB, but it doesn't return any values when the limit is exceeded, as shown in the screenshots. I know the query should return more results, but when I set a limit of 75, for example, it doesn't return anything. The strangest part is that no error is generated, and there's no information in the logs that explains why this is happening.
Steps to Reproduce
This is the query I’m running:
{
"collection": "PaymentProviderMerchantPreferences",
"query": {}
,"limit": 74
}
However, when I increase the limit to 75, the query does not return any results:
Another point I noticed is that when I specify a field, the query returns without any issues.
Any idea what might be causing the error?
Technical details:
- Redash Version: 24.08.1-dev (c1a60bf)
- Browser/OS: Chrome
- How did you install Redash: Helm chart
Hello,
Adding extra informations to the issue related by @diegotiendanube
Here is the error I've found on the logs for the error
2024-09-05T12:43:34.824417052Z [2024-09-05 12:43:34,824][PID:110][ERROR][rq.worker] [Job aedc66dc-423e-4007-a070-787834eace81]: exception raised while executing (redash.tasks.queries.execution.execute_query)
2024-09-05T12:43:34.824435773Z Traceback (most recent call last):
2024-09-05T12:4
3:34.824440053Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1204, in _execute_context
context = constructor(dialect, self, conn, *args)
2024-09-05T12:43:34.824447524Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 873, in _init_compiled
2024-09-05T12:43:34.824451213Z param = dict(
2024-09-05T12:43:34.824454595Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 876, in
2024-09-05T12:43:34.824484725Z processorskey
2024-09-05T12:43:34.824488344Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py", line 1232, in process
return process_param(value, dialect)
2024-09-05T12:43:34.824494215Z File "/app/redash/models/types.py", line 40, in process_bind_param
return json_dumps(value)
2024-09-05T12:43:34.824499665Z File "/app/redash/utils/init.py", line 131, in json_dumps
return json.dumps(data, *args, **kwargs)
2024-09-05T12:43:34.824514556Z File "/usr/local/lib/python3.10/json/init.py", line 238, in dumps
2024-09-05T12:43:34.824517175Z **kw).encode(obj)
2024-09-05T12:43:34.824519796Z File "/usr/local/lib/python3.10/json/encoder.py", line 199, in encode
2024-09-05T12:43:34.824522316Z chunks = self.iterencode(o, _one_shot=True)
2024-09-05T12:43:34.824524785Z File "/usr/local/lib/python3.10/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
2024-09-05T12:43:34.824529677Z File "/app/redash/utils/init.py", line 113, in default
2024-09-05T12:43:34.824532167Z result = super().default(o)
2024-09-05T12:43:34.824534576Z File "/usr/local/lib/python3.10/json/encoder.py", line 179, in default
2024-09-05T12:43:34.824537106Z raise TypeError(f'Object of type {o.class.name} '
2024-09-05T12:43:34.824539527Z TypeError: Object of type Decimal128 is not JSON serializable
2024-09-05T12:43:34.824544517Z The above exception was the direct cause of the following exception:
2024-09-05T12:43:34.824546807Z
2024-09-05T12:43:34.824549247Z Traceback (most recent call last):
2024-09-05T12:43:34.824563688Z File "/usr/local/lib/python3.10/site-packages/rq/worker.py", line 1431, in perform_job
2024-09-05T12:43:34.824566138Z rv = job.perform()
2024-09-05T12:43:34.824568667Z File "/usr/local/lib/python3.10/site-packages/rq/job.py", line 1280, in perform
2024-09-05T12:43:34.824571078Z self._result = self._execute()
2024-09-05T12:43:34.824573618Z File "/usr/local/lib/python3.10/site-packages/rq/job.py", line 1317, in _execute
result = self.func(*self.args, **self.kwargs)
2024-09-05T12:43:34.824578618Z File "/app/redash/tasks/queries/execution.py", line 309, in execute_query
).run()
2024-09-05T12:43:34.824583758Z File "/app/redash/tasks/queries/execution.py", line 253, in run
2024-09-05T12:43:34.824586467Z updated_query_ids = models.Query.update_latest_result(query_result)
2024-09-05T12:43:34.824589238Z File "/app/redash/models/init.py", line 729, in update_latest_result
2024-09-05T12:43:34.824591827Z for q in queries:
2024-09-05T12:43:34.824594408Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 3534, in iter
2024-09-05T12:43:34.824596907Z self.session.autoflush()
2024-09-05T12:43:34.824599428Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1633, in autoflush
2024-09-05T12:43:34.824601889Z util.raise(e, with_traceback=sys.exc_info()[2])
2024-09-05T12:43:34.824606948Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 182, in raise
2024-09-05T12:43:34.824609628Z raise exception
2024-09-05T12:43:34.824612228Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1622, in _autoflush
2024-09-05T12:43:34.824614668Z self.flush()
2024-09-05T12:43:34.824617179Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2540, in flush
2024-09-05T12:43:34.824619729Z self.flush(objects)
2024-09-05T12:43:34.824622159Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2681, in flush
2024-09-05T12:43:34.824624639Z with util.safe_reraise():
2024-09-05T12:43:34.824627228Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 68, in exit
2024-09-05T12:43:34.824629859Z compat.raise(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 182, in raise
2024-09-05T12:43:34.824637549Z raise exception
2024-09-05T12:43:34.824640109Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2642, in _flush
flush_context.execute()
2024-09-05T12:43:34.824645100Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
2024-09-05T12:43:34.824647540Z rec.execute(self)
2024-09-05T12:43:34.824650050Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 586, in execute
2024-09-05T12:43:34.824652560Z persistence.save_obj(
2024-09-05T12:43:34.824656520Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 239, in save_obj
2024-09-05T12:43:34.824659189Z _emit_insert_statements(
2024-09-05T12:43:34.824662189Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 1135, in _emit_insert_statements
2024-09-05T12:43:34.824664780Z result = cached_connections[connection].execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
2024-09-05T12:43:34.824681221Z return meth(self, multiparams, params)
2024-09-05T12:43:34.824683870Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
2024-09-05T12:43:34.824686481Z return connection._execute_clauseelement(self, multiparams, params)
2024-09-05T12:43:34.824689150Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1124, in _execute_clauseelement
ret = self._execute_context(
2024-09-05T12:43:34.824694161Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1206, in _execute_context
2024-09-05T12:43:34.824696661Z self.handle_dbapi_exception(
2024-09-05T12:43:34.824699190Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1510, in handle_dbapi_exception
util.raise(
2024-09-05T12:43:34.824704281Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 182, in raise
2024-09-05T12:43:34.824706772Z raise exception
2024-09-05T12:43:34.824709311Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1204, in _execute_context
2024-09-05T12:43:34.824711902Z context = constructor(dialect, self, conn, *args)
2024-09-05T12:43:34.824714431Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 873, in _init_compiled
2024-09-05T12:43:34.824717111Z param = dict(
2024-09-05T12:43:34.824719822Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 876, in
2024-09-05T12:43:34.824722442Z processorskey
2024-09-05T12:43:34.824724982Z File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py", line 1232, in process
2024-09-05T12:43:34.824727551Z return process_param(value, dialect)
2024-09-05T12:43:34.824730212Z File "/app/redash/models/types.py", line 40, in process_bind_param
2024-09-05T12:43:34.824732682Z return json_dumps(value)
File "/app/redash/utils/init.py", line 131, in json_dumps
2024-09-05T12:43:34.824737742Z return json.dumps(data, *args, **kwargs)
2024-09-05T12:43:34.824740282Z File "/usr/local/lib/python3.10/json/init.py", line 238, in dumps
**kw).encode(obj)
2024-09-05T12:43:34.824745373Z File "/usr/local/lib/python3.10/json/encoder.py", line 199, in encode
2024-09-05T12:43:34.824747903Z chunks = self.iterencode(o, _one_shot=True)
2024-09-05T12:43:34.824752783Z File "/usr/local/lib/python3.10/json/encoder.py", line 257, in iterencode
2024-09-05T12:43:34.824755533Z return _iterencode(o, 0)
2024-09-05T12:43:34.824758133Z File "/app/redash/utils/init.py", line 113, in default
result = super().default(o)
2024-09-05T12:43:34.824763152Z File "/usr/local/lib/python3.10/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
2024-09-05T12:43:34.824768423Z sqlalchemy.exc.StatementError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
2024-09-05T12:43:34.824770973Z (builtins.TypeError) Object of type Decimal128 is not JSON serializable
2024-09-05T12:43:34.824775463Z [SQL: INSERT INTO query_results (org_id, data_source_id, query_hash, query, data, runtime, retrieved_at) VALUES (%(org_id)s, %(data_source_id)s, %(query_hash)s, %(query)s, %(data)s, %(runtime)s, %(retrieved_at)s) RETURNING query_results.id]
2024-09-05T12:43:34.824778683Z [parameters: [{'runtime': 0.12670493125915527, 'retrieved_at': datetime.datetime(2024, 9, 5, 12, 43, 34, 808700, tzinfo=), 'data': {'columns': [{'name': '_id' ... (7788 characters truncated) ... erchantPreferences",\n "query": {}\n ,"limit": 4\n}\n\n', 'data_source_id': 131, 'org_id': 1, 'query_hash': '845a7a68d1075e070a9ff38664a113bd'}]]
I see some PR with a fix for a similar errors but we are using the latest image of Redash here
Any clues @arikfr ?