bmuraykhi opened a new pull request, #45793:
URL: https://github.com/apache/superset/pull/45793

   ### SUMMARY
   
   Drill to detail, dataset samples and the SQL Lab table preview select every 
column as-is. For a ClickHouse `AggregateFunction(...)` column that is the raw 
aggregate state, which clickhouse-connect intentionally does not decode, so the 
whole query fails with `deserialization not supported`. Fixes #45791.
   
   This maps `AggregateFunction` columns to a SQLAlchemy type whose 
`column_expression` selects `finalizeAggregation(col)`, so the column returns 
its per-row value (the median for `quantileTiming`, the distinct count for 
`uniq`). It applies only in the SELECT list; WHERE and ORDER BY are unchanged. 
The ClickHouse `_get_fields` uses the same type, so the table preview SQL does 
too. `SimpleAggregateFunction` columns are unaffected. The mapping needs a 
generic type; NUMERIC matches what the common states (uniq, quantile, sum, avg, 
count) finalize to.
   
   ClickHouse 25.8 to 25.10 have a separate server bug reading any 
`AggregateFunction` column in a `WHERE ... ORDER BY ... LIMIT` query 
(`rows_offset ... is non-zero`), with or without this change. It is fixed in 
25.12.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Drill to detail on a table with `AggregateFunction` columns:
   
   Before:
   <img width="1752" height="600" alt="before" 
src="https://github.com/user-attachments/assets/90d9d20a-ab53-45ef-a207-73615807f685";
 />
   
   After:
   <img width="1752" height="842" alt="after" 
src="https://github.com/user-attachments/assets/b353c6af-88d0-4089-ab38-ec38dcc4a6d6";
 />
   
   ### TESTING INSTRUCTIONS
   
   - `pytest tests/unit_tests/db_engine_specs/test_clickhouse.py -k 
aggregate_function`: the new tests (column spec, table preview SQL, dataset 
query SQL) fail on `master` and pass with this change.
   - Against ClickHouse, with the table from #45791: Drill to detail and the 
SQL Lab table preview fail before this change and return rows with finalized 
values after it.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #45791
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


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