Skip to content

Commit

Permalink
allow description columns to be dimensions of charts (#42539)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxnddr committed May 14, 2024
1 parent 47148ce commit 0ecb5b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions frontend/src/metabase-lib/v1/types/utils/isa.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ export const isScope = isFieldType.bind(null, SCOPE);
export const isCategory = isFieldType.bind(null, CATEGORY);
export const isLocation = isFieldType.bind(null, LOCATION);

export const isDimension = col =>
col && col.source !== "aggregation" && !isDescription(col);
export const isDimension = col => col && col.source !== "aggregation";
export const isMetric = col =>
col && col.source !== "breakout" && isSummable(col);

Expand Down
16 changes: 16 additions & 0 deletions frontend/src/metabase-lib/v1/types/utils/isa.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,25 @@ import {
getFieldType,
isString,
isInteger,
isDimension,
} from "metabase-lib/v1/types/utils/isa";
import { createMockColumn } from "metabase-types/api/mocks";

describe("isa", () => {
describe("isDimension", () => {
it("should should return false for aggregation columns", () => {
expect(isDimension(createMockColumn({ source: "aggregation" }))).toBe(
false,
);
});

it("should should return true for description column types", () => {
expect(
isDimension(createMockColumn({ semantic_type: TYPE.Description })),
).toBe(true);
});
});

describe("getFieldType", () => {
it("should know a date", () => {
expect(getFieldType({ base_type: TYPE.Date })).toEqual(TEMPORAL);
Expand Down

0 comments on commit 0ecb5b0

Please sign in to comment.