-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Explore]Ensure ad-hoc metrics are not named the same as an existing column #13426
Comments
Maybe the SQL query generator should prefix all adhoc metric/sort by with table names instead: SELECT
SUM(tbl.cost) AS "cost"
FROM tbl
ORDER BY
SUM(tbl.cost) |
Good idea @ktmud , should not be difficult to implement |
I’m not sure I agree, i.e., one shouldn’t need to include a table alias in order for these queries to work. Additionally it might not be apparent to the user from the UI what they’re actually doing given there are multiple “columns” with the same name. Furthermore each engine has a perspective on how this should be treated (and how the Finally this used to work and thus it seems there’s been a regression somewhere (possibly related to the other linked issue) and thus I think we should first try to track that down. I guess the TL;DR from me is we should strive for defining concise SQL and let the various SQLAlchemy dialects deal with the SQL nuances. |
@john-bodley AdhocMetrics are always created from the datasource columns so I think from a user's perspective, it is expected that the aggregation should apply only to known columns of the underlying table (be it virtual or physical)---not another ad-hoc metric or derived column. A table name prefix will be totally transparent to the UI and users would not need to do anything extra. It is needed to create a concise & correct SQL query because in this case we obviously didn't give SQLAlchemy enough hints to generate unambiguous SQL queries for all data engines. |
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
),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
SORT BY
.RUN
.Environment
(please complete the following information):
master
3.7
node -v
Checklist
Make sure to follow these steps before submitting your issue - thank you!
The text was updated successfully, but these errors were encountered: