mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
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:
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.',
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user