mirror of
https://github.com/apache/superset.git
synced 2026-04-25 19:14:27 +00:00
feat: generate consistent QueryObject whether GenericAxis is enabled or disabled (#21519)
This commit is contained in:
@@ -18,11 +18,12 @@
|
||||
*/
|
||||
import {
|
||||
buildQueryContext,
|
||||
DTTM_ALIAS,
|
||||
ensureIsArray,
|
||||
normalizeOrderBy,
|
||||
PostProcessingPivot,
|
||||
QueryFormData,
|
||||
getXAxis,
|
||||
isXAxisSet,
|
||||
} from '@superset-ui/core';
|
||||
import {
|
||||
rollingWindowOperator,
|
||||
@@ -38,8 +39,7 @@ import {
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
export default function buildQuery(formData: QueryFormData) {
|
||||
const { x_axis, groupby } = formData;
|
||||
const is_timeseries = x_axis === DTTM_ALIAS || !x_axis;
|
||||
const { groupby } = formData;
|
||||
return buildQueryContext(formData, baseQueryObject => {
|
||||
/* the `pivotOperatorInRuntime` determines how to pivot the dataframe returned from the raw query.
|
||||
1. If it's a time compared query, there will return a pivoted dataframe that append time compared metrics. for instance:
|
||||
@@ -66,18 +66,17 @@ export default function buildQuery(formData: QueryFormData) {
|
||||
baseQueryObject,
|
||||
)
|
||||
? timeComparePivotOperator(formData, baseQueryObject)
|
||||
: pivotOperator(formData, {
|
||||
...baseQueryObject,
|
||||
index: x_axis,
|
||||
is_timeseries,
|
||||
});
|
||||
: pivotOperator(formData, baseQueryObject);
|
||||
|
||||
return [
|
||||
{
|
||||
...baseQueryObject,
|
||||
columns: [...ensureIsArray(x_axis), ...ensureIsArray(groupby)],
|
||||
columns: [
|
||||
...(isXAxisSet(formData) ? ensureIsArray(getXAxis(formData)) : []),
|
||||
...ensureIsArray(groupby),
|
||||
],
|
||||
series_columns: groupby,
|
||||
is_timeseries,
|
||||
...(isXAxisSet(formData) ? {} : { is_timeseries: true }),
|
||||
// todo: move `normalizeOrderBy to extractQueryFields`
|
||||
orderby: normalizeOrderBy(baseQueryObject).orderby,
|
||||
time_offsets: isTimeComparison(formData, baseQueryObject)
|
||||
@@ -92,10 +91,7 @@ export default function buildQuery(formData: QueryFormData) {
|
||||
rollingWindowOperator(formData, baseQueryObject),
|
||||
timeCompareOperator(formData, baseQueryObject),
|
||||
resampleOperator(formData, baseQueryObject),
|
||||
renameOperator(formData, {
|
||||
...baseQueryObject,
|
||||
is_timeseries,
|
||||
}),
|
||||
renameOperator(formData, baseQueryObject),
|
||||
contributionOperator(formData, baseQueryObject),
|
||||
flattenOperator(formData, baseQueryObject),
|
||||
// todo: move prophet before flatten
|
||||
|
||||
Reference in New Issue
Block a user