john-bodley opened a new issue #13426:
URL: https://github.com/apache/superset/issues/13426
We should prevent ad-hoc metrics from being named the same as existing
columns in the datasource as depending on the engine the generated SQL could
result in a projection issue given it's not evident which column is being
referred to.
### Expected results
Ensure all metric names are unique to prevent such an issue.
### Actual results
Presto queries of the form (generated using an ad-hoc query with the metric
named `cost`),
```sql
SELECT
SUM(cost) AS "cost"
FROM
...
ORDER BY
SUM(cost)
```
result in the database error `Invalid reference to output projection
attribute from ORDER BY aggregation`.
#### Screenshots
If applicable, add screenshots to help explain your problem.
#### How to reproduce the bug
1. Go to explore
2. Create an ad-hoc metric which is named the same as an existing column in
the datasource.
3. Add the same ad-hoc metric to the `SORT BY`.
4. Click `RUN`.
5. See the error.
### 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]