Skip to content

Commit

Permalink
fix: Allows X-Axis Sort By for custom SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Sep 25, 2024
1 parent 046c096 commit 37caadd
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
GenericDataType,
getColumnLabel,
getMetricLabel,
isPhysicalColumn,
QueryFormColumn,
QueryFormMetric,
t,
Expand Down Expand Up @@ -66,10 +67,16 @@ function isForcedCategorical(controls: ControlStateMapping): boolean {
}

function isSortable(controls: ControlStateMapping): boolean {
const xAxisValue = controls?.x_axis?.value as QueryFormColumn;
// Given that we don't know the type of a custom SQL column,
// we treat it as sortable and give the responsibility to the
// user to provide a sortable result.
const isCustomSQL = !isPhysicalColumn(xAxisValue);
return (
isForcedCategorical(controls) ||
isCustomSQL ||
checkColumnType(
getColumnLabel(controls?.x_axis?.value as QueryFormColumn),
getColumnLabel(xAxisValue),
controls?.datasource?.datasource,
[GenericDataType.String, GenericDataType.Boolean],
)
Expand Down

0 comments on commit 37caadd

Please sign in to comment.