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

   ### SUMMARY
   
   Drill to Detail / samples queries over a **physical BigQuery dataset** 
failed with `400 ... Unrecognized name: \`forecasts.original\`` when a column 
was a nested `STRUCT` field registered with a dotted `column_name` (e.g. 
`forecasts.original.total_cost`). The chart itself rendered fine — only Drill 
to Detail / samples broke.
   
   **Root cause:** In `ExploreMixin.get_sqla_query` 
(`superset/models/helpers.py`), the column-selection branch (`elif columns:`) 
routed plain string columns through `quote()` + sqlglot normalization. For a 
dotted name that collapses the path into a **single** quoted identifier (`` 
`forecasts.original` ``), which BigQuery reads as one flat column name. The 
chart/groupby selection path instead resolves the `TableColumn` and builds 
`sa.column(column_name)`, which BigQuery quotes **per-segment** (`` 
`forecasts`.`original`.`total_cost` ``) and resolves correctly.
   
   ```
   sa.column("a.b.c")  →  `a`.`b`.`c`   ✅
   quote("a.b.c")      →  `a.b.c`       ❌
   ```
   
   **Fix:** In the `elif columns:` branch, short-circuit known columns — when 
`selected in columns_by_name`, resolve directly via 
`convert_tbl_column_to_sqla_col` (the same helper the chart selection path 
uses) before falling back to the `quote()`/normalize path. Non-dotted columns, 
adhoc columns, and virtual datasets are unaffected (same helper, same labels; 
the short-circuit only triggers for registered physical columns).
   
   The filter path was already correct (it resolves via `columns_by_name.get()` 
+ `convert_tbl_column_to_sqla_col`), so no change was needed there.
   
   Fixes [SC-111745](https://app.shortcut.com/preset/story/111745).
   
   ### TESTING INSTRUCTIONS
   
   - New unit test `test_get_sqla_query_dotted_struct_column_bigquery` 
(`tests/unit_tests/models/helpers_test.py`) asserts the dotted STRUCT path is 
quoted per-segment (`` `forecasts`.`original`.`total_cost` ``) and that the 
merged identifier (`` `forecasts.original` ``) does **not** appear, using the 
real BigQuery dialect (`importorskip`).
   - Full `helpers_test.py` (73 tests) passes — no regressions.
   - Manual repro: build an Interactive Table over a physical BigQuery dataset 
with a nested STRUCT column registered as a dotted name, right-click → Drill to 
detail. Previously 400'd; now returns detail rows.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [x] Required feature flags:
   - [x] 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
   
   Related earlier report: PCS-2360 / PPR-442 covers Drill to Detail on a 
nested `ARRAY<STRUCT>` failing with a *different* error; that variant is not 
addressed here.
   


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