Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (Pivot Export): Use dimension alias in sort clause #5643

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 8 additions & 23 deletions web-common/src/features/dashboards/pivot/pivot-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import { mergeMeasureFilters } from "@rilldata/web-common/features/dashboards/fi
import { useMetricsView } from "@rilldata/web-common/features/dashboards/selectors/index";
import { sanitiseExpression } from "@rilldata/web-common/features/dashboards/stores/filter-utils";
import { MetricsExplorerEntity } from "@rilldata/web-common/features/dashboards/stores/metrics-explorer-entity";
import { mapTimeRange } from "@rilldata/web-common/features/dashboards/time-controls/time-range-mappers";
import { useTimeControlStore } from "@rilldata/web-common/features/dashboards/time-controls/time-control-store";
import { mapTimeRange } from "@rilldata/web-common/features/dashboards/time-controls/time-range-mappers";
import { TimeRangeString } from "@rilldata/web-common/lib/time/types";
import {
createQueryServiceExport,
V1ExportFormat,
V1MetricsViewAggregationRequest,
V1TimeGrain,
createQueryServiceExport,
V1TimeRange,
V1MetricsViewAggregationRequest,
} from "@rilldata/web-common/runtime-client";
import { derived, get } from "svelte/store";
import { runtime } from "../../../runtime-client/runtime-store";
import type { StateManagers } from "../state-managers/state-managers";
import { getPivotConfig } from "./pivot-data-store";
import { prepareMeasureForComparison } from "./pivot-utils";
import {
COMPARISON_DELTA,
COMPARISON_PERCENT,
Expand All @@ -22,9 +25,6 @@ import {
PivotRows,
PivotState,
} from "./types";
import { prepareMeasureForComparison } from "./pivot-utils";
import { getPivotConfig } from "./pivot-data-store";
import { TimeRangeString } from "@rilldata/web-common/lib/time/types";

export default async function exportPivot({
ctx,
Expand Down Expand Up @@ -183,24 +183,9 @@ export function getPivotAggregationRequest(

// Sort by the dimensions in the pivot's rows
const sort = rowDimensions.map((d) => {
// NOTE: This the default sorting in the pivot aggregation query
if (!pivotState.sorting.length) {
return {
name: d.name,
desc: true,
};
}

if (d.alias) {
return {
name: d.alias,
desc: false,
};
}

return {
name: d.name,
desc: false,
name: d.alias ? d.alias : d.name,
desc: pivotState.sorting.find((s) => s.id === d.name)?.desc ?? false,
};
});

Expand Down