john-bodley opened a new issue #13423:
URL: https://github.com/apache/superset/issues/13423
If the metric name/expression is the same as the SORT BY metric, the SORT BY
metric is re-added to the SELECT clause (necessary for sorting) which results
in selecting the expression twice which then introduces ambiguity resulting in
the query engine returning an error.
### Expected results
The SORT BY metric should not be re-added to the SELECT clause.
### Actual results
Depending on the engine an error may be thrown, i.e., for Presto:
```
line 65:10: Column 'sum(total)' is ambiguous
```
#### Screenshots
If applicable, add screenshots to help explain your problem.
#### How to reproduce the bug
1. Go to explorer.
2. Add a metric to both the `METRICS` section (chart dependent) and `SORT
BY`.
3. Click `RUN`.
4. Possibly see the error and notice that the metric is duplicated in the
SQL, i.e.,
```
SELECT
...
sum("total") AS "SUM(total)",
sum("total") AS "SUM(total)"
```
### Environment
(please complete the following information):
- superset version: `master`
- python version: `3.7`
- node.js version: `node -v`
### Checklist
Make sure to follow these steps before submitting your issue - thank you!
- [ ] I have checked the superset logs for python stacktraces and included
it here as text if there are any.
- [ ] I have reproduced the issue with at least the latest released version
of superset.
- [ ] I have checked the issue tracker for the same issue and I haven't
found one similar.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]