timfursov opened a new issue, #33551:
URL: https://github.com/apache/superset/issues/33551

   ### Bug description
   
   ### Describe the bug
   When a metric in a chart is created, clickhouse connect mutates a metric 
label
   
   For example an expression `max(number)` with a name `max_n` will be 
presented in a query as `max(number) AS max_n_23e7d4` which does not allow to 
later refer this metric by it's defined name `max_n` and which eventually 
breaks a very powerful ability of clickhouse - to refer to previously defined 
aliases
   
   The same applies to virtual columns in datasets and the inability to sort by 
aliases, forcing users to copy-paste the entire metric expression in all places
   
   ### Steps to reproduce
   1. Create new chart
   2. Add one or two metrics (eg `max(number) as max_m`, `min(number) as min_m`)
   3. Try to refer one of the previously created metrics from a new metric by 
it's name (eg max_n - min_n )
   
   ### Expected behaviour
   clickhouse conenct does not mutate aliases so they can be referenced in the 
same way as when using clickhouse_driver
   
   ### clickhouse-connect and/or ClickHouse server logs
   ```
   Code: 47. DB::Exception: Unknown expression or function identifier `max_n` 
in scope SELECT number AS number_b1bc24, max(number) AS max_n_23e7d4, 
min(number) AS min_n_78d46f, max_n - min_n AS `max_n - min_n_fddf4f` FROM 
(SELECT number FROM numbers(10)) AS virtual_table GROUP BY number ORDER BY 
max_n_23e7d4 DESC 
   ```
   
   ### Configuration
   #### Environment
   * clickhouse-connect version: 0.8.17
   
   #### ClickHouse server
   * ClickHouse Server version: 25.4
   
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.10
   
   ### Node version
   
   18 or greater
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [ ] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to