wuqicyber opened a new pull request, #37521:
URL: https://github.com/apache/superset/pull/37521
### SUMMARY
When using server-side pagination in table charts, sorting by custom SQL
expression columns (adhoc columns) fails with:
Error: Unknown column used in orderby: <column_label>
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
<img width="1166" height="288" alt="image"
src="https://github.com/user-attachments/assets/09231e46-4be9-4f16-a223-8bad2d4970db"
/>
After:
<img width="621" height="348" alt="image"
src="https://github.com/user-attachments/assets/289e3a1e-7fa9-4237-a89e-6b1d3bb1b584"
/>
### ROOT CAUSE
In superset/models/helpers.py, the orderby validation loop (lines
~2767-2810) handles:
- Adhoc metrics via utils.is_adhoc_metric(col)
- Named metrics via lookup in metrics_exprs_by_label
- Physical columns via lookup in columns_by_name
### TESTING INSTRUCTIONS
1. Create a table chart with server-side pagination enabled
2. Add a custom SQL expression column (e.g., {"expressionType": "SQL",
"label": "custom_col", "sqlExpression": "column_a + 1"})
3. Click the adhoc column header to sort
4. Verify sorting works without error
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [x] Has associated issue: Fixes #37520
- [ ] 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]