Unable to execute Query Based Dropped Down List

I am able to fetch output for the below query in one setup but when i run the same query in another setup with a very similar configuration I am getting the following error when I am using it as a part of Query Based Dropped Down list.

SELECT 'All' AS xxxxname
	UNION ALL
	(SELECT DISTINCT analytics_xxx_xxx_link.xxxx_name AS clientname
	FROM analytics_xxx_xxx_link
	WHERE analytics_xxx_xxx_link.agency_id = 'xxxx'
	ORDER BY analytics_xxx_xxx_link.xxxx_name ASC)

Hi there, where do you see the stack trace error? Is that just in the logs? Can you please paste the complete stack trace (not a screenshot - the actual text)?

[2021-07-19 13:01:31,852][PID:6382][INFO][werkzeug] 10.10.48.218 - - [19/Jul/2021 13:01:31] “POST /DEMO/api/queries/44807 HTTP/1.1” 200 -
[2021-07-19 13:01:31,868] ERROR in app: Exception on /DEMO/api/queries/44807/dropdowns/44804 [GET]
Traceback (most recent call last):
File “/home/ec2-user/softwares/redash/local/lib/python2.7/site-packages/flask/app.py”, line 1612, in full_dispatch_request
rv = self.dispatch_request()
File “/home/ec2-user/softwares/redash/local/lib/python2.7/site-packages/flask/app.py”, line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File “/home/ec2-user/softwares/redash/local/lib/python2.7/site-packages/flask_restful/init.py”, line 477, in wrapper
resp = resource(*args, **kwargs)
File “/home/ec2-user/softwares/redash/local/lib/python2.7/site-packages/flask_login/utils.py”, line 228, in decorated_view
return func(*args, **kwargs)
File “/home/ec2-user/softwares/redash/local/lib/python2.7/site-packages/flask/views.py”, line 84, in view
return self.dispatch_request(*args, **kwargs)
File “/home/ec2-user/softwares/redash/unit-redash/redash/handlers/base.py”, line 31, in dispatch_request
return super(BaseResource, self).dispatch_request(*args, **kwargs)
File “/home/ec2-user/softwares/redash/local/lib/python2.7/site-packages/flask_restful/init.py”, line 587, in dispatch_request
resp = meth(*args, **kwargs)
File “/home/ec2-user/softwares/redash/unit-redash/redash/handlers/query_results.py”, line 183, in get
return dropdown_values(dropdown_query_id, self.current_org)
File “/home/ec2-user/softwares/redash/unit-redash/redash/models/parameterized_query.py”, line 33, in dropdown_values
data = _load_result(query_id, org)
File “/home/ec2-user/softwares/redash/unit-redash/redash/models/parameterized_query.py”, line 26, in _load_result
query_result = models.QueryResult.get_by_id_and_org(query.latest_query_data_id, org)
File “/home/ec2-user/softwares/redash/unit-redash/redash/models/mixins.py”, line 28, in get_by_id_and_org
return query.one()
File “/home/ec2-user/softwares/redash/local/lib64/python2.7/site-packages/sqlalchemy/orm/query.py”, line 2960, in one
raise orm_exc.NoResultFound(“No row was found for one()”)
NoResultFound: No row was found for one()
[2021-07-19 13:01:31,868][PID:6382][INFO][metrics] method=GET path=/DEMO/api/queries/44807/dropdowns/44804 endpoint=query_result_dropdowns status=500 content_type=application/json content_length=36 duration=11.44 query_count=9 query_duration=8.17

Drop down queries are not running in the extended query. But individually they are giving responses.