Skip to content
Snippets Groups Projects
Unverified Commit 433bcb67 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[MLv2] Further StructuredQuery cleanup (#38831)

* Remove unused `StructuredQuery.prototype.topLevelQuery`

* Remove unused `StructuredQuery.prototype.lastSummarizedQuery`

* Remove unused `StructuredQuery.prototype._keyForFK`

* Remove unused `isSegmentOption` helper
parent 2f61b2d7
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,6 @@ import {
isCompatibleAggregationOperatorForField,
} from "metabase-lib/operators/utils";
import { TYPE } from "metabase-lib/types/constants";
import { isSegment } from "metabase-lib/queries/utils/filter";
import { getUniqueExpressionName } from "metabase-lib/queries/utils/expression";
import * as Q from "metabase-lib/queries/utils/query";
import { createLookupByProperty } from "metabase-lib/utils";
......@@ -73,10 +72,6 @@ export interface DimensionOption {
dimension: Dimension;
}
// type guards for determining data types
export const isSegmentOption = (content: any): content is SegmentOption =>
content?.filter && isSegment(content.filter);
export interface SegmentOption {
name: string;
filter: ["segment", number];
......@@ -636,14 +631,6 @@ class StructuredQuery extends AtomicQuery {
}
// DIMENSION OPTIONS
_keyForFK(source, destination) {
if (source && destination) {
return `${source.id},${destination.id}`;
}
return null;
}
dimensionOptions(
dimensionFilter: DimensionFilterFn = _dimension => true,
): DimensionOptions {
......@@ -849,30 +836,6 @@ class StructuredQuery extends AtomicQuery {
return this;
}
/**
* Returns the "last" nested query that is already summarized, or `null` if none are
* */
lastSummarizedQuery = _.once((): StructuredQuery | null | undefined => {
if (this.hasAggregations() || !this.canNest()) {
return this;
} else {
const sourceQuery = this.sourceQuery();
return sourceQuery ? sourceQuery.lastSummarizedQuery() : null;
}
});
/**
* Returns the "last" nested query that is already summarized, or the query itself.
* Used in "view mode" to effectively ignore post-aggregation filter stages
*/
topLevelQuery = _.once((): StructuredQuery => {
if (!this.canNest()) {
return this;
} else {
return this.lastSummarizedQuery() || this;
}
});
/**
* returns the corresponding {Dimension} in the sourceQuery, if any
*/
......
......@@ -69,39 +69,6 @@ describe("StructuredQuery nesting", () => {
});
});
describe("topLevelQuery", () => {
it("should return the query if it's summarized", () => {
const { ordersTable } = setup();
const q = ordersTable.legacyQuery();
expect(q.topLevelQuery().legacyQuery()).toEqual({
"source-table": ORDERS_ID,
});
});
it("should return the query if it's not summarized", () => {
const { ordersTable } = setup();
const q = ordersTable.legacyQuery().aggregate(["count"]);
expect(q.topLevelQuery().legacyQuery()).toEqual({
"source-table": ORDERS_ID,
aggregation: [["count"]],
});
});
it("should return last stage if none are summarized", () => {
const { ordersTable } = setup();
const q = ordersTable.legacyQuery().nest();
expect(q.topLevelQuery().legacyQuery()).toEqual({
"source-query": { "source-table": ORDERS_ID },
});
});
it("should return last summarized stage if any is summarized", () => {
const { ordersTable } = setup();
const q = ordersTable.legacyQuery().aggregate(["count"]).nest();
expect(q.topLevelQuery().legacyQuery()).toEqual({
"source-table": ORDERS_ID,
aggregation: [["count"]],
});
});
});
describe("model question", () => {
it("should not include implicit join dimensions when the underyling question has an explicit join", () => {
const fields = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment