fix(chart): word cloud secondary sort prevents Druid TopN optimization when sort_by_metric enabled (#39073)

Co-authored-by: Brian Donovan <briand@netflix.com>
This commit is contained in:
bdonovan1
2026-04-20 12:28:31 -07:00
committed by GitHub
parent 06818008c2
commit 78fb09695b
4 changed files with 172 additions and 13 deletions

View File

@@ -21,7 +21,8 @@ import { buildQueryContext, QueryFormOrderBy } from '@superset-ui/core';
import { WordCloudFormData } from '../types';
export default function buildQuery(formData: WordCloudFormData) {
const { metric, sort_by_metric, series, row_limit } = formData;
const { metric, sort_by_metric, sort_by_series, series, row_limit } =
formData;
const orderby: QueryFormOrderBy[] = [];
const shouldApplyOrderBy =
row_limit !== undefined && row_limit !== null && row_limit !== 0;
@@ -29,7 +30,7 @@ export default function buildQuery(formData: WordCloudFormData) {
if (sort_by_metric && metric) {
orderby.push([metric, false]);
}
if (series) {
if (sort_by_series && series) {
orderby.push([series, true]);
}

View File

@@ -35,6 +35,22 @@ const config: ControlPanelConfig = {
['adhoc_filters'],
['row_limit'],
['sort_by_metric'],
[
{
name: 'sort_by_series',
config: {
type: 'CheckboxControl',
label: t('Sort by series'),
default: false,
description: t(
'Sort results by series name in ascending order. ' +
'When combined with "Sort by metric", this acts as a tiebreaker ' +
'for equal metric values. Adding this sort may reduce query ' +
'performance on some databases.',
),
},
},
],
],
},
{