Error when trying any Python query on a Python Data Source

Issue Summary

When trying any Python query, I get the following error: Error running query: 'NoneType' object has no attribute 'annotate_query'

Technical details:

  • Redash Version: 8.0.0.b32245
  • Browser/OS: Ubuntu
  • How did you install Redash: Setup script : (commit cb47626b6823cbafac407b3e8991e97f53121f6e)

Redash hosted on a Docker container, itself on an Ubuntu VM.

Enabled Python query by inserting
REDASH_ADDITIONAL_QUERY_RUNNERS: redash.query_runner.python
in the docker-compse.yml file under service>server>environment.

After running docker-compose restart, I was able to create a Python data Source. When trying any python script, I get the error : Error running query: 'NoneType' object has no attribute 'annotate_query'.

By looking into the docker-compose logs, I assume the error comes from the adhoc_worker:

adhoc_worker_1      | Traceback (most recent call last):
adhoc_worker_1      |   File "/usr/local/lib/python2.7/site-packages/celery/app/", line 385, in trace_task
adhoc_worker_1      |     R = retval = fun(*args, **kwargs)
adhoc_worker_1      |   File "/app/redash/", line 84, in __call__
adhoc_worker_1      |     return TaskBase.__call__(self, *args, **kwargs)
adhoc_worker_1      |   File "/usr/local/lib/python2.7/site-packages/celery/app/", line 648, in __protected_call__
adhoc_worker_1      |     return*args, **kwargs)
adhoc_worker_1      |   File "/app/redash/tasks/", line 436, in execute_query
adhoc_worker_1      |     scheduled_query).run()
adhoc_worker_1      |   File "/app/redash/tasks/", line 358, in run
adhoc_worker_1      |     annotated_query = self._annotate_query(query_runner)
adhoc_worker_1      |   File "/app/redash/tasks/", line 408, in _annotate_query
adhoc_worker_1      |     return query_runner.annotate_query(self.query, self.metadata)
adhoc_worker_1      | AttributeError: 'NoneType' object has no attribute 'annotate_query'

May someone help me with this issue ?

Are you sure all your code is up-to-date?

Prior to this PR annotation was handled by the task runner. But it moved to the query runner with a default implementation built-into BaseQueryRunner. It seems like your task runner expects the Python query runner to have a .annotate_query() method but the query runner doesn’t have one, so it fails.

Thanks for your anwer.

As I installed Redash about 4 months ago from the github setup script, I would say it is. The PR you mentionned is from September '19.