{"record":{"id":"0ee064787a203fd4","repo":"getredash/redash","slug":"query-does-not-have-results-yet","errorCode":null,"errorMessage":"Query does not have results yet.","messagePattern":"Query does not have results yet\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"redash/query_runner/python.py","lineNumber":281,"sourceCode":"\n        Parameters:\n        :query_id integer: ID of existing query\n        \"\"\"\n        user = self._get_current_user()\n\n        try:\n            query = models.Query.query.filter(\n                models.Query.id == query_id,\n                models.Query.org_id == user.org_id,\n            ).one()\n        except models.NoResultFound:\n            raise Exception(\"Query id %s does not exist.\" % query_id)\n\n        if query.data_source is None or not has_access(query.data_source, user, view_only):\n            raise Exception(\"You do not have access to query id %s.\" % query_id)\n\n        if query.latest_query_data is None:\n            raise Exception(\"Query does not have results yet.\")\n\n        if query.latest_query_data.data is None:\n            raise Exception(\"Query does not have results yet.\")\n\n        if query.latest_query_data.data_source is None or not has_access(\n            query.latest_query_data.data_source, user, view_only\n        ):\n            raise Exception(\"You do not have access to query id %s.\" % query_id)\n\n        return query.latest_query_data.data\n\n    def dataframe_to_result(self, result, df):\n        converted_result = pandas_to_result(df)\n\n        result[\"rows\"] = converted_result[\"rows\"]\n        for column in converted_result[\"columns\"]:\n            self.add_result_column(result, column[\"name\"], column[\"friendly_name\"], column[\"type\"])\n","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/query_runner/python.py#L263-L299","documentation":"get_query_result() raises this when query.latest_query_data is None — the referenced query has never been executed successfully, so there are no cached results to return. The Python helper serves stored results, it does not execute the query for you.","triggerScenarios":"Calling get_query_result(id) on a freshly created query that has never run, or on a query whose previous results were deleted (e.g. after data retention cleanup or an execution error left no result).","commonSituations":"Creating a new query and immediately using its id in a Python query; scheduled queries disabled so results never materialized; all results purged by cleanup.","solutions":["Open the referenced query in Redash and execute it once ('Execute') so latest_query_data is populated","Schedule the referenced query if you need results to always exist","Re-run the Python query after the underlying query completes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"q = load_query(qid, org)\nassert q.latest_query_data is not None, 'execute the source query at least once first'","typeGuard":null,"tryCatchPattern":"try:\n    get_query_result(qid)\nexcept Exception as e:\n    if 'does not have results yet' in str(e):\n        trigger_execution(qid); wait_for_result(qid); get_query_result(qid)","preventionTips":["Run a query once manually before referencing it in Python queries","Schedule source queries so results are always materialized"],"tags":["redash","python-runner","no-results","state"],"backgroundTag":"query-results-not-materialized","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}