Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Apr 20, 2022
1 parent 2fc9d1d commit a4cbd74
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ export const renameOperator: PostProcessingFactory<PostProcessingRename> = (
queryObject,
) => {
const metrics = ensureIsArray(queryObject.metrics);
if (metrics.length === 1) {
const columns = ensureIsArray(queryObject.columns);
const { x_axis: xAxis } = formData;
// remove metric name in the MultiIndex when
// 1) only 1 metric
// 2) exist dimentsion
// 3) exist xAxis
if (
metrics.length === 1 &&
columns.length > 0 &&
(xAxis || queryObject.is_timeseries)
) {
const mainQueryMetricName = getMetricLabel(metrics[0]);
return {
operation: 'rename',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ import { getMetricOffsetsMap, isValidTimeCompare } from './utils';
export const timeCompareRenameOperator: PostProcessingFactory<PostProcessingRename> =
(formData, queryObject) => {
const metrics = ensureIsArray(queryObject.metrics);
const columns = ensureIsArray(queryObject.columns);
const { x_axis: xAxis } = formData;
// remove metric name in the MultiIndex when
// 1) only 1 metric
// 2) exist dimentsion
// 3) exist xAxis
if (
metrics.length === 1 &&
columns.length > 0 &&
(xAxis || queryObject.is_timeseries) &&
// "actual values" will add derived metric.
isValidTimeCompare(formData, queryObject) &&
formData.comparison_type === ComparisionType.Values
Expand Down

0 comments on commit a4cbd74

Please sign in to comment.