Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Nov 26, 2022
1 parent 9296c87 commit c225baa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const sortOperator: PostProcessingFactory<PostProcessingSort> = (
queryObject,
) => {
// the sortOperator only used in the barchart v2
const labelsInMetricsAndXAxis = [
const sortableLabels = [
getXAxisLabel(formData),
...ensureIsArray(formData.metrics).map(metric => getMetricLabel(metric)),
].filter(Boolean);
Expand All @@ -41,7 +41,7 @@ export const sortOperator: PostProcessingFactory<PostProcessingSort> = (
hasGenericChartAxes &&
isDefined(formData?.x_axis_sort) &&
isDefined(formData?.x_axis_sort_asc) &&
labelsInMetricsAndXAxis.includes(formData.x_axis_sort) &&
sortableLabels.includes(formData.x_axis_sort) &&
// the sort operator doesn't support sort-by multiple series.
isEmpty(formData.groupby)
) {
Expand Down
4 changes: 2 additions & 2 deletions superset/utils/pandas_postprocessing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _is_multi_index_on_columns(df: DataFrame) -> bool:
return isinstance(df.columns, pd.MultiIndex)


def scalar_to_list(val: Any) -> Sequence[str]:
def scalar_to_sequence(val: Any) -> Sequence[str]:
if val is None:
return []
if isinstance(val, str):
Expand All @@ -119,7 +119,7 @@ def wrapped(df: DataFrame, **options: Any) -> Any:
columns = df.columns.tolist()
for name in argnames:
if name in options and not all(
elem in columns for elem in scalar_to_list(options.get(name))
elem in columns for elem in scalar_to_sequence(options.get(name))
):
raise InvalidPostProcessingError(
_("Referenced columns not available in DataFrame.")
Expand Down

0 comments on commit c225baa

Please sign in to comment.