EBoisseauSierra opened a new issue #15060: URL: https://github.com/apache/superset/issues/15060
When creating a “calculated column” `foo` (defined, e.g. as `col1 + col2`), I can't reuse it in the “custom metric” `bar`, as the generated SQL query uses `foo` literally (rather than expanding into its `col1 + col2` definition). This fails as `foo` doesn't actually exist as a column in the table I query. ## Expected results 1. I define a **calculated column** (here, as the difference of 2 columns of my PostgreSQL table):  2. I define a **custom metrics** that notably **reuses my previously defined calculated column**:  I want to be able to now build charts using that custom metrics:  This means, running the following query: ```sql SELECT DATE_TRUNC('hour', timestamp) AS __timestamp, AVG(ABS(temperature_feelslike - temperature))::numeric(10, 2)/AVG(temperature) AS avg_temp_offset FROM public.weather_forecast GROUP BY DATE_TRUNC('hour', timestamp) LIMIT 50000; ``` ### Actual results However, trying to use the custom metrics in Explore fails:  Indeed, the following query is executed: ```sql SELECT DATE_TRUNC('hour', timestamp) AS __timestamp, AVG(ABS(feelslike_offset))::numeric(10, 2)/AVG(temperature) AS avg_temp_offset FROM public.weather_forecast GROUP BY DATE_TRUNC('hour', timestamp) LIMIT 50000; ``` (I.e. the `feelslike_offset` calculated column is not expanded to its definition: `temperature_feelslike - temperature`.) ## Environment (please complete the following information): - superset version: `1.1.0` - python version: `3.8.9` - 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. - [x] I have reproduced the issue with at least the latest released version of superset. - [x] 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]
