rdg0 opened a new pull request, #42040: URL: https://github.com/apache/superset/pull/42040
<!--- Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/ Example: fix(dashboard): load charts correctly --> ### SUMMARY Calculated columns selected as adhoc column references in raw-records queries (no groupby/metrics) had their stored SQL expression dropped on engines whose `quote()` wraps identifiers (e.g. ClickHouse). The previous inline handling in the `elif columns:` branch of `get_sqla_query` looked up the column via dialect-quoted keys (`quoted_columns_by_name`) and silently fell back to `literal_column(<name>)`, emitting a bare column reference that does not exist physically — breaking drill-to-detail and samples queries on nested/calculated columns. This change: - Delegates adhoc columns to `adhoc_column_to_sqla` (mirroring the `need_groupby` branch) so the stored expression is resolved via metadata lookup. - Resolves the processed identifier against the canonical unquoted column names (`columns_by_name`) instead of the dialect-quoted map. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF ### TESTING INSTRUCTIONS 1. Run the regression test: ```bash pytest tests/unit_tests/models/helpers_test.py::test_get_sqla_query_calculated_column_inlined_in_raw_records -v ``` 2. The test verifies that a calculated column (`CASE WHEN a > 0 THEN 'positive' ELSE 'non-positive' END`) selected as an adhoc column reference in a raw-records query has its stored expression inlined into the generated SQL rather than emitted as a bare `name_test` reference. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [x] Has associated issue: Fixes #34784 - [ ] 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]
