kokhlo commented on issue #44343:
URL: https://github.com/apache/superset/issues/44343#issuecomment-5696077210

   I dug into the current main and I think I can explain what changed, and it's 
a real regression rather than an intended rule change.
   
   **Diagnosis**
   
   The "Y-Axis Sort By" (horizontal) / "X-Axis Sort By" control is gated by 
`isSortable()` in 
`superset-frontend/packages/superset-ui-chart-controls/src/utils/isSortable.ts` 
(introduced by #30393, shipped in 4.1/5.0 — that's why 3.0.0 still had the 
control unconditionally-ish). It returns true only when the axis column is:
   
   1. numeric **and** "Force categorical" is checked — but "Force categorical" 
is itself only rendered for numeric columns (`xAxisForceCategoricalControl` 
visibility in `shared-controls/customControls.tsx`), and
   2. custom SQL (non-physical column), or
   3. of type String or Boolean (`checkColumnType` → requires `type_generic` ∈ 
{String, Boolean}).
   
   Your `g_code` is a **physical** column whose `type_generic` is `undefined` 
(that's exactly the `?` icon: the backend couldn't map the raw MySQL type to a 
generic type), so it fails all three branches and the sort control is hidden — 
even though ordering categories by a metric is perfectly valid for an 
unknown-typed string column.
   
   The pre-#30393 gate (#21993) was type-agnostic (`isDefined(x_axis) && 
!isTemporalColumn && groupby empty`), which is why 3.0.0 showed it for your 
chart. The `test_end_year` chart works because its column is numeric → "Force 
categorical" appears → branch 1 opens the sort control.
   
   **Why `?` on a virtual dataset**: `type_generic` is derived by the backend 
from the raw type via the generic-type map; for some MySQL types/expressions in 
virtual datasets the mapping misses, leaving the column as UNKNOWN. That part 
is data/backend-dependent, but the UI shouldn't hide sorting for it.
   
   **Plan**
   
   I'll open a PR within the hour:
   
   - extend `isSortable()` so a physical column with `type_generic === 
undefined` (unknown type) is treated as sortable, mirroring the existing 
"custom SQL is sortable, responsibility is on the user" rationale in the same 
file;
   - regression tests in `test/utils/isSortable.test.ts` for the unknown-type 
column case (both plain and with force-categorical off).
   
   That directly restores your 3.x behaviour (sort by `Amount GFR`) without 
touching type detection.
   


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