mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(table): Use extras in queries (#30335)
This commit is contained in:
@@ -114,8 +114,8 @@ const buildQuery: BuildQuery<TableChartFormData> = (
|
||||
}
|
||||
}
|
||||
|
||||
let temporalColumAdded = false;
|
||||
let temporalColum = null;
|
||||
let temporalColumnAdded = false;
|
||||
let temporalColumn = null;
|
||||
|
||||
if (queryMode === QueryMode.Aggregate) {
|
||||
metrics = metrics || [];
|
||||
@@ -169,23 +169,23 @@ const buildQuery: BuildQuery<TableChartFormData> = (
|
||||
time_grain_sqla &&
|
||||
temporalColumnsLookup?.[col];
|
||||
|
||||
if (shouldBeAdded && !temporalColumAdded) {
|
||||
temporalColum = {
|
||||
if (shouldBeAdded && !temporalColumnAdded) {
|
||||
temporalColumn = {
|
||||
timeGrain: time_grain_sqla,
|
||||
columnType: 'BASE_AXIS',
|
||||
sqlExpression: col,
|
||||
label: col,
|
||||
expressionType: 'SQL',
|
||||
} as AdhocColumn;
|
||||
temporalColumAdded = true;
|
||||
temporalColumnAdded = true;
|
||||
return false; // Do not include this in the output; it's added separately
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// So we ensure the temporal column is added first
|
||||
if (temporalColum) {
|
||||
columns = [temporalColum, ...columns];
|
||||
if (temporalColumn) {
|
||||
columns = [temporalColumn, ...columns];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,10 +198,15 @@ const buildQuery: BuildQuery<TableChartFormData> = (
|
||||
(ownState.currentPage ?? 0) * (ownState.pageSize ?? 0);
|
||||
}
|
||||
|
||||
if (!temporalColumn) {
|
||||
// This query is not using temporal column, so it doesn't need time grain
|
||||
extras.time_grain_sqla = undefined;
|
||||
}
|
||||
|
||||
let queryObject = {
|
||||
...baseQueryObject,
|
||||
columns,
|
||||
extras: !isEmpty(timeOffsets) && !temporalColum ? {} : extras,
|
||||
extras,
|
||||
orderby,
|
||||
metrics,
|
||||
post_processing: postProcessing,
|
||||
@@ -239,7 +244,6 @@ const buildQuery: BuildQuery<TableChartFormData> = (
|
||||
row_limit: 0,
|
||||
row_offset: 0,
|
||||
post_processing: [],
|
||||
extras: undefined, // we don't need time grain here
|
||||
order_desc: undefined, // we don't need orderby stuff here,
|
||||
orderby: undefined, // because this query will be used for get total aggregation.
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user