Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Replace leftover usages of 'pMBQL' with 'MBQL 5' (#72066)

Cam Saul4ae75fc5e67e
diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn
index 5161d27a9db..ebf49594ca6 100644
--- a/.clj-kondo/config.edn
+++ b/.clj-kondo/config.edn
@@ -471,8 +471,8 @@
metabase.premium-features.settings/define-premium-feature clojure.core/def
metabase.pulse.dashboard-subscription-test/with-dashboard-sub-for-card clojure.core/let
metabase.pulse.send-test/with-pulse-for-card clojure.core/let
- metabase.query-processor.pipeline-queries-test/pmbql-query clojure.core/->
- metabase.query-processor.pipeline-queries-test/run-pmbql-query clojure.core/->
+ metabase.query-processor.pipeline-queries-test/mbql5-query clojure.core/->
+ metabase.query-processor.pipeline-queries-test/run-mbql5-query clojure.core/->
metabase.query-processor.error-type/deferror clojure.core/def
metabase.query-processor.middleware.cache.impl/with-reducible-deserialized-results clojure.core/let
metabase.query-processor.middleware.process-userland-query-test/with-query-execution! clojure.core/let
diff --git a/.cljfmt.edn b/.cljfmt.edn
index 917375aefbc..3b77231aae7 100644
--- a/.cljfmt.edn
+++ b/.cljfmt.edn
@@ -188,8 +188,8 @@
metabase.query-processor.error-type/deferror [[:block 1]]
metabase.query-processor.middleware.cache-backend.interface/with-cached-results [[:block 4]]
metabase.query-processor.middleware.process-userland-query-test/with-query-execution [[:block 1]]
- metabase.query-processor.pipeline-queries-test/pmbql-query [[:block 1]]
- metabase.query-processor.pipeline-queries-test/run-pmbql-query [[:block 1]]
+ metabase.query-processor.pipeline-queries-test/mbql5-query [[:block 1]]
+ metabase.query-processor.pipeline-queries-test/run-mbql5-query [[:block 1]]
metabase.query-processor.store/cached [[:block 1]]
metabase.query-processor.store/with-metadata-provider [[:inner 0]]
metabase.query-processor.streaming/streaming-response [[:block 1]]
diff --git a/e2e/test/scenarios/data-studio/measures/measures-data-studio.cy.spec.ts b/e2e/test/scenarios/data-studio/measures/measures-data-studio.cy.spec.ts
index 07de12230bd..ba98bd6b53c 100644
--- a/e2e/test/scenarios/data-studio/measures/measures-data-studio.cy.spec.ts
+++ b/e2e/test/scenarios/data-studio/measures/measures-data-studio.cy.spec.ts
@@ -319,7 +319,7 @@ describe("scenarios > data studio > data model > measures", () => {
aggregation: ["count"],
});
cy.get<number>("@measureId").then((measureId) => {
- // Fetch the measure to get the current pMBQL definition
+ // Fetch the measure to get the current MBQL 5 definition
cy.request("GET", `/api/measure/${measureId}`).then(({ body }) => {
const currentDefinition = body.definition;
@@ -340,7 +340,7 @@ describe("scenarios > data studio > data model > measures", () => {
});
cy.log("update measure aggregation");
- // Update aggregation in the pMBQL definition
+ // Update aggregation in the MBQL 5 definition
const updatedDefinition = {
...currentDefinition,
stages: [
diff --git a/enterprise/backend/src/metabase_enterprise/replacement/walk.clj b/enterprise/backend/src/metabase_enterprise/replacement/walk.clj
index ed05f89cca0..d16ea44622a 100644
--- a/enterprise/backend/src/metabase_enterprise/replacement/walk.clj
+++ b/enterprise/backend/src/metabase_enterprise/replacement/walk.clj
@@ -26,7 +26,7 @@
(try
;; `value_field` and `label_field` are legacy refs
#_{:clj-kondo/ignore [:discouraged-var]}
- (-> legacy-ref lib/->pMBQL (ref-fn card-id) lib/->legacy-MBQL)
+ (-> legacy-ref lib/->mbql5 (ref-fn card-id) lib/->legacy-MBQL)
(catch Exception _
legacy-ref)))]
(mapv (fn [parameter]
@@ -63,7 +63,7 @@
ref-fn :- fn?]
(letfn [(update-legacy-ref-or-name [ref-or-name]
(or (when (vector? ref-or-name)
- (when-some [ref (try (lib/->pMBQL ref-or-name) (catch Exception _ nil))]
+ (when-some [ref (try (lib/->mbql5 ref-or-name) (catch Exception _ nil))]
(when-some [ref-or-name' (ref-fn ref)]
(when (string? ref-or-name')
ref-or-name'))))
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/column_comparison.clj b/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/column_comparison.clj
index 34002d0a218..b31cb0c9919 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/column_comparison.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/column_comparison.clj
@@ -20,7 +20,7 @@
;;; -------------------------------------------------- Query Building --------------------------------------------------
(defn- make-distribution-query
- "Generate a pMBQL query for field distribution."
+ "Generate a MBQL 5 query for field distribution."
[db-id table-id field-id]
(let [mp (lib-be/application-database-metadata-provider db-id)
table-metadata (lib.metadata/table mp table-id)
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/generic.clj b/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/generic.clj
index 192bef463ef..b84612c91ca 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/generic.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/generic.clj
@@ -19,7 +19,7 @@
;;; -------------------------------------------------- Query Building --------------------------------------------------
(defn- make-count-query
- "Generate a pMBQL COUNT(*) query."
+ "Generate a MBQL 5 COUNT(*) query."
[db-id table-id]
(let [mp (lib-be/application-database-metadata-provider db-id)
table-metadata (lib.metadata/table mp table-id)]
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/query_util.clj b/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/query_util.clj
index 98bcfa4ac37..5d2fa93f55b 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/query_util.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_inspector/lens/query_util.clj
@@ -1,5 +1,5 @@
(ns metabase-enterprise.transforms-inspector.lens.query-util
- "Shared utilities for manipulating preprocessed pMBQL queries in lens code."
+ "Shared utilities for manipulating preprocessed MBQL 5 queries in lens code."
(:require
[metabase.lib.core :as lib]))
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj b/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj
index d3325b41719..ffb46506044 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj
@@ -244,7 +244,7 @@
- sources: source table info (with fields) for native column resolution
Returns:
- {:preprocessed-query <pMBQL> (MBQL only)
+ {:preprocessed-query <MBQL 5> (MBQL only)
:driver <keyword> (native only)
:from-table-id <int> (native only)
:from-table <honeysql> (native only)
diff --git a/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.clj b/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.clj
index bac1421d691..5278b0e63a6 100644
--- a/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.clj
@@ -919,7 +919,7 @@
{:model "Field" :id "Some Field"}]}
(set (serdes/dependencies ser))))))))))
-(defn- pmbql-measure-definition
+(defn- mbql5-measure-definition
"Create an MBQL5 measure definition with a sum aggregation."
[db-id table-id field-id]
(let [metadata-provider (lib-be/application-database-metadata-provider db-id)
@@ -936,7 +936,7 @@
:model/Database {db-id :id} {:name "My Database"}
:model/Table {no-schema-id :id} {:name "Schemaless Table" :db_id db-id}
:model/Field {field-id :id} {:name "Some Field" :table_id no-schema-id}]
- (let [definition (pmbql-measure-definition db-id no-schema-id field-id)]
+ (let [definition (mbql5-measure-definition db-id no-schema-id field-id)]
(ts/with-temp-dpc [:model/Measure
{m1-id :id
m1-eid :entity_id}
@@ -974,7 +974,7 @@
:model/Database {db-id :id} {:name "My Database"}
:model/Table {table-id :id} {:name "My Table" :db_id db-id}
:model/Field {field-id :id} {:name "Amount" :table_id table-id}]
- (let [base-definition (pmbql-measure-definition db-id table-id field-id)]
+ (let [base-definition (mbql5-measure-definition db-id table-id field-id)]
(ts/with-temp-dpc [:model/Measure
{m1-id :id
m1-eid :entity_id}
diff --git a/enterprise/backend/test/metabase_enterprise/transforms_inspector/context_test.clj b/enterprise/backend/test/metabase_enterprise/transforms_inspector/context_test.clj
index a363e8a7598..b21253dc243 100644
--- a/enterprise/backend/test/metabase_enterprise/transforms_inspector/context_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/transforms_inspector/context_test.clj
@@ -120,7 +120,7 @@
(lib/with-join-fields :all))))))
(defn- native-orders-query
- "Build a native-only pMBQL query selecting from the orders table."
+ "Build a native-only MBQL 5 query selecting from the orders table."
[]
{:lib/type :mbql/query
:lib/metadata (mt/metadata-provider)
diff --git a/enterprise/backend/test/metabase_enterprise/workspaces/test_util.clj b/enterprise/backend/test/metabase_enterprise/workspaces/test_util.clj
index a3a77e694e9..ace7a1f4c2c 100644
--- a/enterprise/backend/test/metabase_enterprise/workspaces/test_util.clj
+++ b/enterprise/backend/test/metabase_enterprise/workspaces/test_util.clj
@@ -78,7 +78,7 @@
(lib/query mp (lib.metadata/table mp (mt/id table-kw)))))
(defn mbql->native
- "Compile a query to a native SQL map. Works with both legacy MBQL and lib (pMBQL) queries.
+ "Compile a query to a native SQL map. Works with both legacy MBQL and lib (MBQL 5) queries.
This generates driver-specific SQL with properly qualified table names."
[query]
(qp.store/with-metadata-provider (mt/id)
diff --git a/resources/openapi/openapi.json b/resources/openapi/openapi.json
index 98620ba86fb..b074fb5407b 100644
--- a/resources/openapi/openapi.json
+++ b/resources/openapi/openapi.json
@@ -11702,7 +11702,7 @@
"type" : "string"
},
"metabase.lib.schema.metadata.stage" : {
- "description" : "Metadata about the columns returned by a particular stage of a pMBQL query. For example a single-stage native query\n like\n\n {:database 1\n :lib/type :mbql/query\n :stages [{:lib/type :mbql.stage/mbql\n :native \"SELECT id, name FROM VENUES;\"}]}\n\n might have stage metadata like\n\n {:columns [{:name \"id\", :base-type :type/Integer}\n {:name \"name\", :base-type :type/Text}]}\n\n associated with the query's lone stage.\n\n At some point in the near future we will hopefully attach this metadata directly to each stage in a query, so a\n multi-stage query will have `:lib/stage-metadata` for each stage. The main goal is to facilitate things like\n returning lists of visible or filterable columns for a given stage of a query. This is TBD, see #28717 for a WIP\n implementation of this idea.\n\n This is the same format as the results metadata returned with QP results in `data.results_metadata`. The `:columns`\n portion of this (`data.results_metadata.columns`) is also saved as `Card.result_metadata` for Saved Questions.\n\n Note that queries currently actually come back with both `data.results_metadata` AND `data.cols`; it looks like the\n Frontend actually *merges* these together -- see `applyMetadataDiff` in\n `frontend/src/metabase/query_builder/selectors.js` -- but this is ridiculous. Let's try to merge anything missing in\n `results_metadata` into `cols` going forward so things don't need to be manually merged in the future.",
+ "description" : "Metadata about the columns returned by a particular stage of a MBQL 5 query. For example a single-stage native query\n like\n\n {:database 1\n :lib/type :mbql/query\n :stages [{:lib/type :mbql.stage/mbql\n :native \"SELECT id, name FROM VENUES;\"}]}\n\n might have stage metadata like\n\n {:columns [{:name \"id\", :base-type :type/Integer}\n {:name \"name\", :base-type :type/Text}]}\n\n associated with the query's lone stage.\n\n At some point in the near future we will hopefully attach this metadata directly to each stage in a query, so a\n multi-stage query will have `:lib/stage-metadata` for each stage. The main goal is to facilitate things like\n returning lists of visible or filterable columns for a given stage of a query. This is TBD, see #28717 for a WIP\n implementation of this idea.\n\n This is the same format as the results metadata returned with QP results in `data.results_metadata`. The `:columns`\n portion of this (`data.results_metadata.columns`) is also saved as `Card.result_metadata` for Saved Questions.\n\n Note that queries currently actually come back with both `data.results_metadata` AND `data.cols`; it looks like the\n Frontend actually *merges* these together -- see `applyMetadataDiff` in\n `frontend/src/metabase/query_builder/selectors.js` -- but this is ridiculous. Let's try to merge anything missing in\n `results_metadata` into `cols` going forward so things don't need to be manually merged in the future.",
"properties" : {
"columns" : {
"items" : {
@@ -49499,4 +49499,4 @@
"description" : "Metabase API",
"url" : ""
} ]
-}
\ No newline at end of file
+}
diff --git a/src/metabase/agent_api/api.clj b/src/metabase/agent_api/api.clj
index 4d94eae3c55..2fb353128b5 100644
--- a/src/metabase/agent_api/api.clj
+++ b/src/metabase/agent_api/api.clj
@@ -610,15 +610,15 @@
(-> token u/decode-base64 json/decode+kw))
(defn- build-query-for-execution
- "Construct a pMBQL query map from table_id or metric_id params. Returns {:query <map> :limit <int>}.
- The JSON round-trip strips lib metadata so the query is a plain pMBQL map suitable for token serialization."
+ "Construct a MBQL 5 query map from table_id or metric_id params. Returns {:query <map> :limit <int>}.
+ The JSON round-trip strips lib metadata so the query is a plain MBQL 5 map suitable for token serialization."
[body]
(let [limit (min (or (:limit body) default-query-row-limit) max-query-row-limit)
query (construct-query* (assoc body :limit limit))]
{:query (json/decode+kw (json/encode query)) :limit limit}))
(defn- apply-page-to-query
- "Apply :page clause to the last stage of a pMBQL query map."
+ "Apply :page clause to the last stage of a MBQL 5 query map."
[query-map page items]
(let [stages (:stages query-map)
last-idx (dec (count stages))]
@@ -667,11 +667,11 @@
{:query query :limit (:limit pagination) :page (:page pagination)})
(let [{:keys [query limit]} (build-query-for-execution body)]
{:query query :limit limit :page 1}))
- pmbql-with-page (apply-page-to-query query page limit)]
+ mbql5-with-page (apply-page-to-query query page limit)]
(qp.streaming/streaming-response
[rff :api]
(qp/process-query
- (prepare-combined-query pmbql-with-page)
+ (prepare-combined-query mbql5-with-page)
(qp.streaming/transforming-query-response
rff
(fn [result]
diff --git a/src/metabase/legacy_mbql/util.cljc b/src/metabase/legacy_mbql/util.cljc
index ecbe45435fb..34867b12f10 100644
--- a/src/metabase/legacy_mbql/util.cljc
+++ b/src/metabase/legacy_mbql/util.cljc
@@ -354,7 +354,7 @@
Note that the optional options map is in different positions for `:contains`, `:does-not-contain`, `:starts-with` and
`:ends-with` depending on the number of arguments. 2-argument forms use the legacy style `[:contains field x opts]`.
- Multi-argument forms use pMBQL style with the options at index 1, **even if there are no options**:
+ Multi-argument forms use MBQL 5 style with the options at index 1, **even if there are no options**:
`[:contains {} field x y z]`."
{:deprecated "0.57.0"}
[m]
diff --git a/src/metabase/lib/convert.cljc b/src/metabase/lib/convert.cljc
index 4a92999241b..a471432b0cd 100644
--- a/src/metabase/lib/convert.cljc
+++ b/src/metabase/lib/convert.cljc
@@ -25,10 +25,10 @@
[metabase.util.performance :refer [mapv some select-keys not-empty #?(:clj doseq) #?(:clj for)]])
#?@(:cljs [(:require-macros [metabase.lib.convert :refer [with-aggregation-list]])]))
-(def ^:private ^:dynamic *pMBQL-uuid->legacy-index*
+(def ^:private ^:dynamic *mbql5-uuid->legacy-index*
{})
-(def ^:private ^:dynamic *legacy-index->pMBQL-uuid*
+(def ^:private ^:dynamic *legacy-index->mbql5-uuid*
{})
(defn- clean-location [almost-stage error-type error-location]
@@ -134,13 +134,13 @@
(*card-clean-hook* almost-query cleaned)))
cleaned)))
-(defmulti ->pMBQL
- "Coerce something to pMBQL (the version of MBQL manipulated by Metabase Lib v2) if it's not already pMBQL."
+(defmulti ->mbql5
+ "Coerce something to MBQL 5 (the version of MBQL manipulated by Metabase Lib v2) if it's not already MBQL 5."
{:arglists '([x])}
lib.dispatch/dispatch-value
:hierarchy lib.hierarchy/hierarchy)
-(defn- default-MBQL-clause->pMBQL [[tag & args :as clause]]
+(defn- default-MBQL-clause->mbql5 [[tag & args :as clause]]
(if (map? (first args))
;; already MBQL 5
clause
@@ -157,16 +157,16 @@
(> (count args) 2) clause
(map? (last args)) (list* tag (last args) (butlast args))
:else (list* tag {} args)))]
- (lib.options/ensure-uuid (into [tag options] (map ->pMBQL) args)))))
+ (lib.options/ensure-uuid (into [tag options] (map ->mbql5) args)))))
-(defmethod ->pMBQL :default
+(defmethod ->mbql5 :default
[x]
(if (and (vector? x)
(keyword? (first x)))
- (default-MBQL-clause->pMBQL x)
+ (default-MBQL-clause->mbql5 x)
x))
-(defmethod ->pMBQL :mbql/query
+(defmethod ->mbql5 :mbql/query
[query]
query)
@@ -175,13 +175,13 @@
normally had an explicit `:alias` since the QB would generate one and you generally need one to do useful things
with the join anyway.
- Since the new pMBQL schema makes `:alias` required, we'll explicitly add the implicit default when we encounter a
+ Since the new MBQL 5 schema makes `:alias` required, we'll explicitly add the implicit default when we encounter a
join without an alias, and remove it so we can round-trip without changes."
"__join")
(defn- deduplicate-join-aliases
"Join `:alias`es had to be unique in legacy MBQL, but they were optional. Since we add [[legacy-default-join-alias]]
- to each join that doesn't have an explicit `:alias` for pMBQL compatibility now, we need to deduplicate the aliases
+ to each join that doesn't have an explicit `:alias` for MBQL 5 compatibility now, we need to deduplicate the aliases
if it is used more than once.
Only deduplicate the default `__join` aliases; we don't want the [[lib.util/unique-name-generator]] to touch other
@@ -193,8 +193,8 @@
(= (:alias join) legacy-default-join-alias) (update :alias unique-name-fn)))
joins)))
-(defn- stage-source-card-id->pMBQL
- "If a query `stage` has a legacy `card__<id>` `:source-table`, convert it to a pMBQL-style `:source-card`."
+(defn- stage-source-card-id->mbql5
+ "If a query `stage` has a legacy `card__<id>` `:source-table`, convert it to a MBQL 5-style `:source-card`."
[stage]
(if (string? (:source-table stage))
(-> stage
@@ -205,35 +205,35 @@
(defn do-with-aggregation-list
"Impl for [[with-aggregation-list]]."
[aggregations thunk]
- (let [legacy->pMBQL (into {}
+ (let [legacy->mbql5 (into {}
(map-indexed (fn [idx [_tag {ag-uuid :lib/uuid}]]
[idx ag-uuid]))
aggregations)
- pMBQL->legacy (set/map-invert legacy->pMBQL)]
- (binding [*legacy-index->pMBQL-uuid* legacy->pMBQL
- *pMBQL-uuid->legacy-index* pMBQL->legacy]
+ mbql5->legacy (set/map-invert legacy->mbql5)]
+ (binding [*legacy-index->mbql5-uuid* legacy->mbql5
+ *mbql5-uuid->legacy-index* mbql5->legacy]
(thunk))))
#?(:clj
(defmacro with-aggregation-list
"Macro for capturing the context of a query stage's `:aggregation` list, so any legacy `[:aggregation 0]` indexed
- refs can be converted correctly to UUID-based pMBQL refs."
+ refs can be converted correctly to UUID-based MBQL 5 refs."
[aggregations & body]
`(do-with-aggregation-list ~aggregations (fn [] ~@body))))
-(defn- index-ref-clauses->pMBQL [clauses]
+(defn- index-ref-clauses->mbql5 [clauses]
(letfn [(pass [state]
(reduce (fn [{:keys [index index->uuid converted] :as state} clause]
(-> (if (get converted index)
state
(try
- (let [pMBQL (binding [*legacy-index->pMBQL-uuid* index->uuid]
- (->pMBQL clause))]
+ (let [mbql5 (binding [*legacy-index->mbql5-uuid* index->uuid]
+ (->mbql5 clause))]
(-> state
- (update :index->uuid assoc index (lib.options/uuid pMBQL))
- (update :converted assoc index pMBQL)))
+ (update :index->uuid assoc index (lib.options/uuid mbql5))
+ (update :converted assoc index mbql5)))
(catch #?(:cljs js/Error :clj clojure.lang.ExceptionInfo) e
- (if (= (-> e ex-data :error) ::legacy-index->pMBQL-uuid-missing)
+ (if (= (-> e ex-data :error) ::legacy-index->mbql5-uuid-missing)
state
(throw e)))))
(update :index inc)))
@@ -257,9 +257,9 @@
acc
(= (:lib/source col) :source/aggregations)
- (let [ag-uuid (or (get *legacy-index->pMBQL-uuid* aggregation-index)
+ (let [ag-uuid (or (get *legacy-index->mbql5-uuid* aggregation-index)
(throw (ex-info (str "Missing UUID for aggregation at index " aggregation-index)
- {:legacy-index->pMBQL-uuid *legacy-index->pMBQL-uuid*
+ {:legacy-index->mbql5-uuid *legacy-index->mbql5-uuid*
:aggregation-index aggregation-index})))
col' (assoc col :lib/source-uuid ag-uuid)]
(recur (conj acc col') (inc aggregation-index) more))
@@ -281,44 +281,44 @@
(log/error e "Error adding :lib/source-uuid to cols")
cols)))
-(defmethod ->pMBQL :mbql.stage/mbql
+(defmethod ->mbql5 :mbql.stage/mbql
[stage]
- (let [stage (m/update-existing stage :aggregation index-ref-clauses->pMBQL)
+ (let [stage (m/update-existing stage :aggregation index-ref-clauses->mbql5)
expressions (->> stage
:expressions
(mapv (fn [[k v]]
(-> v
- ->pMBQL
+ ->mbql5
(lib.util/top-level-expression-clause k))))
not-empty)]
(metabase.lib.convert/with-aggregation-list (:aggregation stage)
(let [stage (-> stage
- stage-source-card-id->pMBQL
+ stage-source-card-id->mbql5
(m/assoc-some :expressions expressions))
stage (reduce
(fn [stage k]
(if-not (get stage k)
stage
- (update stage k ->pMBQL)))
+ (update stage k ->mbql5)))
stage
(disj stage-keys :expressions :aggregation))]
(cond-> stage
(:joins stage) (update :joins deduplicate-join-aliases)
(:lib/stage-metadata stage) (update-in [:lib/stage-metadata :columns] add-source-uuids-to-cols expressions))))))
-(defmethod ->pMBQL :mbql.stage/native
+(defmethod ->mbql5 :mbql.stage/native
[stage]
- (m/update-existing stage :template-tags update-vals (fn [tag] (m/update-existing tag :dimension ->pMBQL))))
+ (m/update-existing stage :template-tags update-vals (fn [tag] (m/update-existing tag :dimension ->mbql5))))
-(defmethod ->pMBQL :mbql/join
+(defmethod ->mbql5 :mbql/join
[join]
(let [join (-> join
- (update :conditions ->pMBQL)
- (update :stages ->pMBQL))]
+ (update :conditions ->mbql5)
+ (update :stages ->mbql5))]
(cond-> join
(:fields join) (update :fields (fn [fields]
(if (sequential? fields)
- (mapv ->pMBQL fields)
+ (mapv ->mbql5 fields)
(keyword fields))))
(not (:alias join)) (assoc :alias legacy-default-join-alias)
;; MBQL 5 does not support `:parameters` at the top level of a join, so move them to the join's first stage.
@@ -334,36 +334,36 @@
(:parameters join) (-> (update-in [:stages 0 :parameters] #(into (vec %) (:parameters join)))
(dissoc :parameters)))))
-(defmethod ->pMBQL :dispatch-type/sequential
+(defmethod ->mbql5 :dispatch-type/sequential
[xs]
- (mapv ->pMBQL xs))
+ (mapv ->mbql5 xs))
-(defmethod ->pMBQL :dispatch-type/map
+(defmethod ->mbql5 :dispatch-type/map
[m]
(if (:type m)
(-> (lib.util/pipeline m)
(update :stages (fn [stages]
- (mapv ->pMBQL stages)))
+ (mapv ->mbql5 stages)))
lib.normalize/normalize
(assoc :lib.convert/converted? true)
clean)
- (update-vals m ->pMBQL)))
+ (update-vals m ->mbql5)))
-(defmethod ->pMBQL :field
+(defmethod ->mbql5 :field
[[_tag x y]]
(let [[id-or-name options] (if (map? x)
[y x]
[x y])]
(lib.options/ensure-uuid [:field options id-or-name])))
-(defmethod ->pMBQL :value
+(defmethod ->mbql5 :value
[[_tag value opts]]
;; `:value` uses `:snake_case` keys in legacy MBQL (this was to match the shape of the keys in Field metadata), at
;; least for the three type keys enumerated below. See [[metabase.legacy-mbql.schema/ValueTypeInfo]].
(let [opts (set/rename-keys opts {:base_type :base-type
:semantic_type :semantic-type
:database_type :database-type})
- ;; in pMBQL, `:effective-type` is a required key for `:value`. `:value` SHOULD have always had `:base-type`,
+ ;; in MBQL 5, `:effective-type` is a required key for `:value`. `:value` SHOULD have always had `:base-type`,
;; but on the off chance it did not, get the type from value so the schema doesn't fail entirely.
opts (assoc opts :effective-type (or (:effective-type opts)
(:base-type opts)
@@ -379,14 +379,14 @@
(lib.options/ensure-uuid [:value opts value])))
(doseq [tag [:case :if]]
- (defmethod ->pMBQL tag
+ (defmethod ->mbql5 tag
[[_tag pred-expr-pairs options]]
(let [default (:default options)]
- (cond-> [tag (dissoc options :default) (mapv ->pMBQL pred-expr-pairs)]
+ (cond-> [tag (dissoc options :default) (mapv ->mbql5 pred-expr-pairs)]
:always lib.options/ensure-uuid
- (some? default) (conj (->pMBQL default))))))
+ (some? default) (conj (->mbql5 default))))))
-(defmethod ->pMBQL :expression
+(defmethod ->mbql5 :expression
[[tag value opts]]
(lib.options/ensure-uuid [tag opts value]))
@@ -399,33 +399,33 @@
{:m m
:k k})))))
-(defmethod ->pMBQL :aggregation
+(defmethod ->mbql5 :aggregation
[[tag aggregation-index opts, :as clause]]
(lib.options/ensure-uuid
- [tag opts (or (get *legacy-index->pMBQL-uuid* aggregation-index)
+ [tag opts (or (get *legacy-index->mbql5-uuid* aggregation-index)
(throw (ex-info (str "Error converting :aggregation reference: no aggregation at index "
aggregation-index)
{:clause clause
- :error ::legacy-index->pMBQL-uuid-missing})))]))
+ :error ::legacy-index->mbql5-uuid-missing})))]))
-(defmethod ->pMBQL :aggregation-options
+(defmethod ->mbql5 :aggregation-options
[[_tag aggregation options]]
- (let [[tag opts & args] (->pMBQL aggregation)]
+ (let [[tag opts & args] (->mbql5 aggregation)]
(into [tag (merge opts options)] args)))
-(defmethod ->pMBQL :datetime
+(defmethod ->mbql5 :datetime
[[_tag value options]]
- (lib.options/ensure-uuid [:datetime (or options {}) (->pMBQL value)]))
+ (lib.options/ensure-uuid [:datetime (or options {}) (->mbql5 value)]))
-(defmethod ->pMBQL :time-interval
+(defmethod ->mbql5 :time-interval
[[_tag field n unit options]]
- (lib.options/ensure-uuid [:time-interval (or options {}) (->pMBQL field) n unit]))
+ (lib.options/ensure-uuid [:time-interval (or options {}) (->mbql5 field) n unit]))
-(defmethod ->pMBQL :relative-time-interval
+(defmethod ->mbql5 :relative-time-interval
[[_tag & [_column _value _bucket _offset-value _offset-bucket :as args]]]
- (lib.options/ensure-uuid (into [:relative-time-interval {}] (map ->pMBQL) args)))
+ (lib.options/ensure-uuid (into [:relative-time-interval {}] (map ->mbql5) args)))
-(defmethod ->pMBQL :relative-datetime
+(defmethod ->mbql5 :relative-datetime
[[_tag n unit]]
(let [normalized-unit (cond-> unit (string? unit) keyword)]
(lib.options/ensure-uuid
@@ -433,28 +433,28 @@
[:relative-datetime {} n normalized-unit]
[:relative-datetime {} n]))))
-;; `:offset` is the same in legacy and pMBQL, but we need to update the expr it wraps.
-(defmethod ->pMBQL :offset
+;; `:offset` is the same in legacy and MBQL 5, but we need to update the expr it wraps.
+(defmethod ->mbql5 :offset
[[tag opts expr n, :as clause]]
{:pre [(= (count clause) 4)]}
- [tag opts (->pMBQL expr) n])
+ [tag opts (->mbql5 expr) n])
;; These four expressions have a different form depending on the number of arguments.
(doseq [tag [:contains :starts-with :ends-with :does-not-contain]]
(lib.hierarchy/derive tag ::string-comparison))
-(defmethod ->pMBQL ::string-comparison
+(defmethod ->mbql5 ::string-comparison
[[tag opts & args :as clause]]
(if (> (count args) 2)
- ;; Multi-arg, pMBQL style: [tag {opts...} x y z ...]
- (lib.options/ensure-uuid (into [tag opts] (map ->pMBQL args)))
+ ;; Multi-arg, MBQL 5 style: [tag {opts...} x y z ...]
+ (lib.options/ensure-uuid (into [tag opts] (map ->mbql5 args)))
;; Two-arg, legacy style: [tag x y] or [tag x y opts].
(let [[tag x y opts] clause]
- (lib.options/ensure-uuid [tag (or opts {}) (->pMBQL x) (->pMBQL y)]))))
+ (lib.options/ensure-uuid [tag (or opts {}) (->mbql5 x) (->mbql5 y)]))))
(defn legacy-query-from-inner-query
"Convert a legacy 'inner query' to a full legacy 'outer query' so you can pass it to stuff
- like [[metabase.legacy-mbql.normalize/normalize]], and then probably to [[->pMBQL]]."
+ like [[metabase.legacy-mbql.normalize/normalize]], and then probably to [[->mbql5]]."
[database-id inner-query]
(merge {:database database-id, :type :query}
(if (:native inner-query)
@@ -492,8 +492,8 @@
`:effective-type`, which is not used in options maps in legacy MBQL."
[m :- [:maybe :map]]
(->> (cond-> m
- ;; Following construct ensures that transformation mbql -> pmbql -> mbql, does not add base-type where those
- ;; were not present originally. Base types are added in [[metabase.lib.query/add-types-to-fields]].
+ ;; Following construct ensures that transformation MBQL 4 -> MBQL 5 -> MBQL 4, does not add base-type where
+ ;; those were not present originally. Base types are added in [[metabase.lib.query/add-types-to-fields]].
(:lib/transformation-added-base-type m)
(dissoc :lib/transformation-added-base-type :base-type))
(into {} (comp (disqualify)
@@ -611,14 +611,14 @@
;; :source-metadata aka :lib/stage-metadata is handled differently in the two formats.
;; In legacy, an inner query might have both :source-query, and :source-metadata giving the metadata for that nested
;; :source-query.
- ;; In pMBQL, the :lib/stage-metadata is attached to the same stage it applies to.
- ;; So when chaining pMBQL stages back into legacy form, if stage n has :lib/stage-metadata, stage n+1 needs
+ ;; In MBQL 5, the :lib/stage-metadata is attached to the same stage it applies to.
+ ;; So when chaining MBQL 5 stages back into legacy form, if stage n has :lib/stage-metadata, stage n+1 needs
;; :source-metadata attached.
(let [inner-query (first (reduce (fn [[inner stage-metadata] stage]
[(cond-> (->legacy-MBQL stage)
inner (assoc :source-query inner)
stage-metadata (assoc :source-metadata (stage-metadata->legacy-metadata stage-metadata)))
- ;; Get the :lib/stage-metadata off the original pMBQL stage, not the converted one.
+ ;; Get the :lib/stage-metadata off the original MBQL 5 stage, not the converted one.
(:lib/stage-metadata stage)])
nil
stages))]
@@ -645,12 +645,12 @@
(if (map? opts)
(try
(let [opts (options->legacy-MBQL opts)
- base-agg [:aggregation (get-or-throw! *pMBQL-uuid->legacy-index* agg-uuid)]]
+ base-agg [:aggregation (get-or-throw! *mbql5-uuid->legacy-index* agg-uuid)]]
(if (seq opts)
(conj base-agg opts)
base-agg))
(catch #?(:clj Throwable :cljs :default) e
- (throw (ex-info (lib.util/format "Error converting aggregation reference to pMBQL: %s" (ex-message e))
+ (throw (ex-info (lib.util/format "Error converting aggregation reference to MBQL 5: %s" (ex-message e))
{:ref ag}
e))))
;; Our conversion is a bit too aggressive and we're hitting legacy refs like [:aggregation 0] inside
@@ -673,11 +673,11 @@
(string? id) ensure-base-type)))
(defn- update-list->legacy-boolean-expression
- [m pMBQL-key legacy-key]
+ [m mbql5-key legacy-key]
(cond-> m
- (= (count (get m pMBQL-key)) 1) (m/update-existing pMBQL-key (comp ->legacy-MBQL first))
- (> (count (get m pMBQL-key)) 1) (m/update-existing pMBQL-key #(into [:and] (map ->legacy-MBQL) %))
- :always (set/rename-keys {pMBQL-key legacy-key})))
+ (= (count (get m mbql5-key)) 1) (m/update-existing mbql5-key (comp ->legacy-MBQL first))
+ (> (count (get m mbql5-key)) 1) (m/update-existing mbql5-key #(into [:and] (map ->legacy-MBQL) %))
+ :always (set/rename-keys {mbql5-key legacy-key})))
(defmethod ->legacy-MBQL :mbql/join [join]
(let [base (cond-> (disqualify join)
@@ -706,7 +706,7 @@
inner-query)))))
(defn- source-card->legacy-source-table
- "If a pMBQL query stage has `:source-card` convert it to legacy-style `:source-table \"card__<id>\"`."
+ "If a MBQL 5 query stage has `:source-card` convert it to legacy-style `:source-table \"card__<id>\"`."
[stage]
(if-let [source-card-id (:source-card stage)]
(-> stage
@@ -772,11 +772,11 @@
;; TODO: Look into whether this function can be refactored away - it's called from several places but I (Braden) think
;; legacy refs shouldn't make it out of `lib.js`.
-(mu/defn legacy-ref->pMBQL :- ::lib.schema.ref/ref
- "Convert a legacy MBQL `:field`/`:aggregation`/`:expression` reference to pMBQL. Normalizes the reference if needed,
+(mu/defn legacy-ref->mbql5 :- ::lib.schema.ref/ref
+ "Convert a legacy MBQL `:field`/`:aggregation`/`:expression` reference to MBQL 5. Normalizes the reference if needed,
and handles JS -> Clj conversion as needed."
([query legacy-ref]
- (legacy-ref->pMBQL query -1 legacy-ref))
+ (legacy-ref->mbql5 query -1 legacy-ref))
([query :- ::lib.schema/query
stage-number :- :int
@@ -787,13 +787,13 @@
{aggregations :aggregation} (lib.util/query-stage query stage-number)]
(with-aggregation-list aggregations
(try
- (->pMBQL legacy-ref)
+ (->mbql5 legacy-ref)
(catch #?(:clj Throwable :cljs :default) e
- (throw (ex-info (lib.util/format "Error converting legacy ref to pMBQL: %s" (ex-message e))
+ (throw (ex-info (lib.util/format "Error converting legacy ref to MBQL 5: %s" (ex-message e))
{:query query
:stage-number stage-number
:legacy-ref legacy-ref
- :legacy-index->pMBQL-uuid *legacy-index->pMBQL-uuid*}
+ :legacy-index->mbql5-uuid *legacy-index->mbql5-uuid*}
e))))))))
(defn- from-json [query-fragment]
@@ -802,22 +802,22 @@
query-fragment)
:clj query-fragment))
-(defn js-legacy-query->pMBQL
- "Given a JSON-formatted legacy MBQL query, transform it to pMBQL.
+(defn js-legacy-query->mbql5
+ "Given a JSON-formatted legacy MBQL query, transform it to MBQL 5.
- If you have only the inner query map (`{:source-table 2 ...}` or similar), call [[js-legacy-inner-query->pMBQL]]
+ If you have only the inner query map (`{:source-table 2 ...}` or similar), call [[js-legacy-inner-query->mbql5]]
instead."
[query-map]
(let [clj-map (from-json query-map)]
(if (= (:lib/type clj-map) "mbql/query")
(lib.normalize/normalize clj-map)
- (-> clj-map (u/assoc-default :type :query) mbql.normalize/normalize ->pMBQL))))
+ (-> clj-map (u/assoc-default :type :query) mbql.normalize/normalize ->mbql5))))
-(defn js-legacy-inner-query->pMBQL
- "Given a JSON-formatted *inner* query, transform it to pMBQL.
+(defn js-legacy-inner-query->mbql5
+ "Given a JSON-formatted *inner* query, transform it to MBQL 5.
- If you have a complete legacy query (`{:type :query, :query {...}}` or similar), call [[js-legacy-query->pMBQL]]
+ If you have a complete legacy query (`{:type :query, :query {...}}` or similar), call [[js-legacy-query->mbql5]]
instead."
[inner-query]
- (js-legacy-query->pMBQL {:type :query
+ (js-legacy-query->mbql5 {:type :query
:query (from-json inner-query)}))
diff --git a/src/metabase/lib/core.cljc b/src/metabase/lib/core.cljc
index f438d6b32f3..76b2e6471a1 100644
--- a/src/metabase/lib/core.cljc
+++ b/src/metabase/lib/core.cljc
@@ -1380,7 +1380,7 @@
external-op]
[lib.convert
->legacy-MBQL
- ->pMBQL
+ ->mbql5
legacy-default-join-alias
with-aggregation-list
without-cleaning]
diff --git a/src/metabase/lib/equality.cljc b/src/metabase/lib/equality.cljc
index 16b2e02aa21..941a2cf7088 100644
--- a/src/metabase/lib/equality.cljc
+++ b/src/metabase/lib/equality.cljc
@@ -1,5 +1,5 @@
(ns metabase.lib.equality
- "Logic for determining whether two pMBQL queries are equal."
+ "Logic for determining whether two MBQL 5 queries are equal."
(:refer-clojure :exclude [= every? some mapv empty? not-empty get-in #?(:clj for)])
(:require
[medley.core :as m]
@@ -24,7 +24,7 @@
[metabase.util.performance :refer [every? some mapv empty? not-empty get-in #?(:clj for)]]))
(defmulti =
- "Determine whether two already-normalized pMBQL maps, clauses, or other sorts of expressions are equal. The basic rule
+ "Determine whether two already-normalized MBQL 5 maps, clauses, or other sorts of expressions are equal. The basic rule
is that two things are considered equal if they are [[clojure.core/=]], or, if they are both maps, if they
are [[clojure.core/=]] if you ignore all qualified keyword keys besides `:lib/type`."
{:arglists '([x y])}
@@ -579,7 +579,7 @@ are known to be the same."
stage-number :- :int
legacy-ref :- :some
metadatas :- [:maybe [:sequential ::lib.schema.metadata/column]]]
- (find-matching-column query stage-number (lib.convert/legacy-ref->pMBQL query stage-number legacy-ref) metadatas)))
+ (find-matching-column query stage-number (lib.convert/legacy-ref->mbql5 query stage-number legacy-ref) metadatas)))
(defn mark-selected-columns
"Mark `columns` as `:selected?` if they appear in `selected-columns-or-refs`. Uses fuzzy matching with
diff --git a/src/metabase/lib/expression.cljc b/src/metabase/lib/expression.cljc
index 72b89efde63..582b0b5d972 100644
--- a/src/metabase/lib/expression.cljc
+++ b/src/metabase/lib/expression.cljc
@@ -545,7 +545,7 @@
(mu/defn with-expression-name :- ::lib.schema.expression/expression
"Return a new expression clause like `an-expression-clause` but with name `new-name`.
- For expressions from the :expressions clause of a pMBQL query this sets the :lib/expression-name option,
+ For expressions from the :expressions clause of a MBQL 5 query this sets the :lib/expression-name option,
for other expressions (for example named aggregation expressions) the :display-name option is set.
Note that always setting :lib/expression-name would lead to confusion, because that option is used
@@ -692,9 +692,9 @@
As a special case, it checks that window functions are not embedded in each other
and in aggregation functions.
- - `expr` is a pMBQL expression usually created from a legacy MBQL expression created
+ - `expr` is a MBQL 5 expression usually created from a legacy MBQL expression created
using the custom column editor in the FE. It is expected to have been normalized and
- converted using [[metabase.lib.convert/->pMBQL]].
+ converted using [[metabase.lib.convert/->mbql5]].
- `expression-mode` specifies what type of thing `expr` is: an :expression (custom column),
an :aggregation expression, or a :filter condition.
- `expression-position` is only defined when editing an existing custom column, and in that case
diff --git a/src/metabase/lib/filter.cljc b/src/metabase/lib/filter.cljc
index 44f3f3755a6..9c9b07ae8b1 100644
--- a/src/metabase/lib/filter.cljc
+++ b/src/metabase/lib/filter.cljc
@@ -324,7 +324,7 @@
:is-empty ((unary-filter-display-fns :is-empty) expr)
:not-empty ((unary-filter-display-fns :is-not-empty) expr)
;; TODO -- This description is sorta wack, we should use [[metabase.legacy-mbql.util/negate-filter-clause]] to
- ;; negate `expr` and then generate a description. That would require porting that stuff to pMBQL tho.
+ ;; negate `expr` and then generate a description. That would require porting that stuff to MBQL 5 tho.
:not ((unary-filter-display-fns :not) expr))))
(defmethod lib.metadata.calculation/display-name-method :value
diff --git a/src/metabase/lib/filter/desugar.cljc b/src/metabase/lib/filter/desugar.cljc
index bb9102c6e71..818101eafad 100644
--- a/src/metabase/lib/filter/desugar.cljc
+++ b/src/metabase/lib/filter/desugar.cljc
@@ -209,7 +209,7 @@
Note that the optional options map is in different positions for `:contains`, `:does-not-contain`, `:starts-with` and
`:ends-with` depending on the number of arguments. 2-argument forms use the legacy style `[:contains field x opts]`.
- Multi-argument forms use pMBQL style with the options at index 1, **even if there are no options**:
+ Multi-argument forms use MBQL 5 style with the options at index 1, **even if there are no options**:
`[:contains {} field x y z]`."
[expr :- ::clause]
(lib.util.match/replace-lite expr
diff --git a/src/metabase/lib/js.cljs b/src/metabase/lib/js.cljs
index 63387cc26ca..ebeb02e8715 100644
--- a/src/metabase/lib/js.cljs
+++ b/src/metabase/lib/js.cljs
@@ -14,7 +14,7 @@
A reference of what is meant in these docs by \"column\", \"query\", etc. Most of the CLJS maps have a `:lib/type`
key, the values are indicated here. TS types are also indicated as eg. `Lib.ColumnMetadata`.
- - **query** means a modern pMBQL query, represented as a CLJS map (`:mbql/query`, `Lib.Query`)
+ - **query** means a modern MBQL 5 query, represented as a CLJS map (`:mbql/query`, `Lib.Query`)
- **legacy query** and **MLv1 query** mean the previous form of MBQL, represented as a JSON object
- **column** means the full details of a column - its name, types, etc. (`:metadata/column`, `Lib.ColumnMetadata`)
- Columns can come from several sources: source tables, cards/models, previous stages of this query, aggregations,
@@ -23,7 +23,7 @@
- **clause** means a fragment of MBQL describing part of a query, such as an aggregation, breakout, join, etc.
- **ref** means a reference to a column.
- Often these are misleading called a \"field ref\", since they are represented as a `[:field ...]` clause in both
- legacy MBQL and pMBQL.
+ legacy MBQL and MBQL 5.
- Refs are a code smell - they are an internal detail of MBQL structures that has leaked into many places in
legacy. All mention of refs should be eliminated from this interface eventually.
@@ -155,7 +155,7 @@
(lib.cache/side-channel-cache-weak-refs
(str database-id) metadata-provider query-map
#(->> %
- lib.convert/js-legacy-query->pMBQL
+ lib.convert/js-legacy-query->mbql5
(lib.core/query metadata-provider))
{:force? true})))
@@ -177,7 +177,7 @@
:else x))
(defn ^:export legacy-query
- "Coerce an MLv2 query (pMBQL in CLJS data structures) into a legacy MLv1 query in vanilla JSON form.
+ "Coerce an MLv2 query (MBQL 5 in CLJS data structures) into a legacy MLv1 query in vanilla JSON form.
> **Code health:** Legacy. This has many legitimate uses (as of March 2024), but we should aim to reduce the places
where a legacy query is still needed. Consider if it's practical to port the consumer of this legacy query to MLv2."
@@ -716,7 +716,7 @@
(-> a-query (js->clj :keywordize-keys true) unwrap normalize*)))
(defn ^:export normalize
- "Normalize the MBQL or pMBQL query `a-query`.
+ "Normalize the MBQL or MBQL 5 query `a-query`.
Returns the JS form of the normalized query."
[a-query]
(-> a-query normalize-to-clj (clj->js :keyword-fn u/qualified-name)))
@@ -812,7 +812,7 @@
It duplicates the logic formerly found in `query_builder/selectors.js`.
> **Code health:** Legacy. New calls are acceptable if necessary. Eventually this will be replaced with an equivalent
- function that compares two pMBQL queries in CLJS form, but that needs pMBQL queries to be the source of truth on the
+ function that compares two MBQL 5 queries in CLJS form, but that needs MBQL 5 queries to be the source of truth on the
wire, rather than legacy."
([query1 query2] (query= query1 query2 nil))
([query1 query2 field-ids]
@@ -1534,13 +1534,13 @@
(u/qualified-name %)
%))))
-(defn- legacy-ref->pMBQL [a-legacy-ref]
+(defn- legacy-ref->mbql5 [a-legacy-ref]
(-> a-legacy-ref
(js->clj :keywordize-keys true)
(update 0 keyword)
#_{:clj-kondo/ignore [:deprecated-var]}
mbql.normalize/normalize-field-ref
- lib.convert/->pMBQL
+ lib.convert/->mbql5
(->> (lib.normalize/normalize ::lib.schema.ref/ref))))
(defn- ref->legacy-ref
@@ -1577,8 +1577,8 @@
;; Convert legacy columns like we do for metadata.
(let [parsed (js.metadata/parse-column legacy-column)]
(if (= (:lib/source parsed) :source/aggregations)
- ;; Special case: Aggregations need to be converted to a pMBQL :aggregation ref and :lib/source-uuid set.
- (let [agg-ref (legacy-ref->pMBQL (.-field_ref legacy-column))]
+ ;; Special case: Aggregations need to be converted to a MBQL 5 :aggregation ref and :lib/source-uuid set.
+ (let [agg-ref (legacy-ref->mbql5 (.-field_ref legacy-column))]
(assoc parsed :lib/source-uuid (last agg-ref)))
parsed))
;; It's already a :metadata/column map
@@ -1594,11 +1594,11 @@
identify a column in viz settings. Avoid new calls if you have an alternative way to find the column you need. But if
you need it, no worries about a new call."
[a-query stage-number legacy-columns legacy-refs]
- ;; Set up this query stage's `:aggregation` list as the context for [[lib.convert/->pMBQL]] to convert legacy
- ;; `[:aggregation 0]` refs into pMBQL `[:aggregation uuid]` refs.
+ ;; Set up this query stage's `:aggregation` list as the context for [[lib.convert/->mbql5]] to convert legacy
+ ;; `[:aggregation 0]` refs into MBQL 5 `[:aggregation uuid]` refs.
(lib.convert/with-aggregation-list (:aggregation (lib.util/query-stage a-query stage-number))
(let [haystack (mapv ->column-or-ref legacy-columns)
- needles (map legacy-ref->pMBQL legacy-refs)
+ needles (map legacy-ref->mbql5 legacy-refs)
column-refs (into {} (keep-indexed (fn [i col]
[(-> col
lib.core/ref
@@ -1984,7 +1984,7 @@
(defn ^:export native-query
"Create a new native query.
- *Native* in this sense means a pMBQL query where the first stage is `:mbql.stage/native`.
+ *Native* in this sense means a MBQL 5 query where the first stage is `:mbql.stage/native`.
> **Code health:** Healthy"
[database-id metadata inner-query]
@@ -2015,7 +2015,7 @@
(perf/update-keys keyword)
(update :type keyword)
(m/update-existing :widget-type #(some-> % keyword))
- (m/update-existing :dimension #(some-> % legacy-ref->pMBQL)))))))
+ (m/update-existing :dimension #(some-> % legacy-ref->mbql5)))))))
(defn- template-tags-cljs->js
[tags]
@@ -2264,7 +2264,7 @@
[a-query stage-number ^js js-column]
(lib.convert/with-aggregation-list (lib.core/aggregations a-query stage-number)
(let [column-ref (when-let [a-ref (.-field_ref js-column)]
- (legacy-ref->pMBQL a-ref))]
+ (legacy-ref->mbql5 a-ref))]
(fix-column-with-ref column-ref (js.metadata/parse-column js-column)))))
(defn ^:export legacy-column->type-info
@@ -2291,7 +2291,7 @@
(fn [^js cell]
(let [column (js.metadata/parse-column (col-fn cell))
column-ref (when-let [a-ref (:field-ref column)]
- (legacy-ref->pMBQL a-ref))]
+ (legacy-ref->mbql5 a-ref))]
{:column (fix-column-with-ref column-ref column)
:column-ref column-ref
:value (.-value cell)})))
@@ -2353,7 +2353,7 @@
[a-query stage-number card-id column value row dimensions]
(lib.convert/with-aggregation-list (lib.core/aggregations a-query stage-number)
(let [column-ref (when-let [a-ref (and column (.-field_ref ^js column))]
- (legacy-ref->pMBQL a-ref))]
+ (legacy-ref->mbql5 a-ref))]
(->> (merge {:column (when column
(fix-column-with-ref column-ref (js.metadata/parse-column column)))
:column-ref column-ref
diff --git a/src/metabase/lib/metadata/result_metadata.cljc b/src/metabase/lib/metadata/result_metadata.cljc
index d55a7394b48..ecf45d1f017 100644
--- a/src/metabase/lib/metadata/result_metadata.cljc
+++ b/src/metabase/lib/metadata/result_metadata.cljc
@@ -489,7 +489,7 @@
(fn [cols]
(or (empty? cols)
(apply distinct? (map ::field-ref cols))))]]
- "Return metadata for columns returned by a pMBQL `query`.
+ "Return metadata for columns returned by a MBQL 5 `query`.
`initial-cols` are (optionally) the initial minimal metadata columns as returned by the driver (usually just column
name and base type). If provided these are merged with the columns the query is expected to return.
diff --git a/src/metabase/lib/metric.cljc b/src/metabase/lib/metric.cljc
index 24116f425b6..bbed9fe08d0 100644
--- a/src/metabase/lib/metric.cljc
+++ b/src/metabase/lib/metric.cljc
@@ -30,7 +30,7 @@
(let [normalized-definition (case (lib.util/normalized-mbql-version dataset-query)
;; TODO (Cam 10/7/25) -- not sure we'll ever see legacy queries here anymore since
;; they get normalized to MBQL 5 coming out of the app DB
- :mbql-version/legacy (-> dataset-query mbql.normalize/normalize lib.convert/->pMBQL)
+ :mbql-version/legacy (-> dataset-query mbql.normalize/normalize lib.convert/->mbql5)
:mbql-version/mbql5 (lib.normalize/normalize ::lib.schema/query dataset-query))]
(lib.util/query-stage normalized-definition -1))))
diff --git a/src/metabase/lib/native.cljc b/src/metabase/lib/native.cljc
index 7f03f21193f..956003b238a 100644
--- a/src/metabase/lib/native.cljc
+++ b/src/metabase/lib/native.cljc
@@ -190,7 +190,7 @@
(mu/defn native-query :- ::lib.schema/query
"Create a new native query.
- Native in this sense means a pMBQL query with a first stage that is a native query."
+ Native in this sense means a MBQL 5 query with a first stage that is a native query."
([metadata-providerable :- ::lib.schema.metadata/metadata-providerable
sql-or-other-native-query :- ::common/non-blank-string]
(native-query metadata-providerable sql-or-other-native-query nil nil))
diff --git a/src/metabase/lib/normalize.cljc b/src/metabase/lib/normalize.cljc
index 4ca9021a406..741b8c387cb 100644
--- a/src/metabase/lib/normalize.cljc
+++ b/src/metabase/lib/normalize.cljc
@@ -69,7 +69,7 @@
(defn normalize
"Ensure some part of an MBQL query `x`, e.g. a clause or map, is in the right shape after coming in from JavaScript or
deserialized JSON (from the app DB or a REST API request). This is intended for things that are already in a
- generally correct pMBQL; to 'normalize' things from legacy MBQL, use [[metabase.lib.convert]].
+ generally correct MBQL 5; to 'normalize' things from legacy MBQL, use [[metabase.lib.convert]].
Normalization logic is defined in various schemas; grep for `:decode/normalize` in the `metabase.lib.schema*`
namespaces.
diff --git a/src/metabase/lib/parameters.cljc b/src/metabase/lib/parameters.cljc
index dc025d18548..0f5883809c2 100644
--- a/src/metabase/lib/parameters.cljc
+++ b/src/metabase/lib/parameters.cljc
@@ -52,7 +52,7 @@
(mu/defn parameter-target-field-ref :- [:maybe :mbql.clause/field]
"If a parameter `:target` wraps a legacy `:field` ref, find it, convert it to MBQL 5, and return it."
[target :- ::lib.schema.parameter/target]
- (some-> target parameter-target-legacy-field-ref lib.convert/->pMBQL))
+ (some-> target parameter-target-legacy-field-ref lib.convert/->mbql5))
(mu/defn parameter-target-field-id :- [:maybe ::lib.schema.id/field]
"If a parameter `:target` wraps a field ID ref return the Field ID."
@@ -81,7 +81,7 @@
(mu/defn parameter-target-expression-ref :- [:maybe :mbql.clause/expression]
"If a parameter `:target` wraps a legacy `:expression` ref, find it, convert it to MBQL 5, and return it."
[target :- ::lib.schema.parameter/target]
- (some-> target parameter-target-legacy-expression-ref lib.convert/->pMBQL))
+ (some-> target parameter-target-legacy-expression-ref lib.convert/->mbql5))
(mu/defn parameter-target-expression-name :- [:maybe :string]
"If a parameter `:target` wraps an `:expression` ref return the expression name."
@@ -118,7 +118,7 @@
0))
(mu/defn update-parameter-target-field-ref :- ::lib.schema.parameter/target
- "If parameter `:target` wraps a legacy `:field` ref, convert it to pMBQL, apply `(apply f field-ref args)`, convert
+ "If parameter `:target` wraps a legacy `:field` ref, convert it to MBQL 5, apply `(apply f field-ref args)`, convert
the result back to legacy, and place it back in the target. If there is no `:field` ref, returns target unchanged."
[target :- ::lib.schema.parameter/target
f & args]
diff --git a/src/metabase/lib/query.cljc b/src/metabase/lib/query.cljc
index 882a881e2d0..5d36c54073b 100644
--- a/src/metabase/lib/query.cljc
+++ b/src/metabase/lib/query.cljc
@@ -123,7 +123,7 @@
(can-run query "question"))
(mu/defn add-types-to-fields
- "Add `:base-type` and `:effective-type` to options of fields in `x` using `metadata-provider`. Works on pmbql fields.
+ "Add `:base-type` and `:effective-type` to options of fields in `x` using `metadata-provider`. Works on MBQL 5 fields.
`:effective-type` is required for coerced fields to pass schema checks."
[x metadata-provider :- ::lib.schema.metadata/metadata-provider]
(if-let [field-ids (lib.util.match/match-many x
@@ -149,7 +149,7 @@
(:base-type (lib.metadata/field metadata-provider id))))
;; Following key is used to track which base-types we added during `query` call. It is used in
;; [[metabase.lib.convert/options->legacy-MBQL]] to remove those, so query after conversion
- ;; as legacy -> pmbql -> legacy looks closer to the original.
+ ;; as legacy -> MBQL 5 -> legacy looks closer to the original.
(merge (when-not (contains? options :base-type)
{:lib/transformation-added-base-type true})
(-> (lib.metadata/field metadata-provider id)
@@ -178,7 +178,7 @@
[metadata-providerable legacy-query]
(try
(let [mbql5-query (binding [lib.schema.expression/*suppress-expression-type-check?* true]
- (lib.convert/->pMBQL (mbql.normalize/normalize-or-throw legacy-query)))
+ (lib.convert/->mbql5 (mbql.normalize/normalize-or-throw legacy-query)))
mp (lib.metadata/->metadata-provider metadata-providerable (:database mbql5-query))
mbql5-query (add-types-to-fields mbql5-query mp)]
(merge
@@ -206,7 +206,7 @@
(defmethod query-method :dispatch-type/map
[metadata-providerable query]
- (query-method metadata-providerable (assoc (lib.convert/->pMBQL query) :lib/type :mbql/query)))
+ (query-method metadata-providerable (assoc (lib.convert/->mbql5 query) :lib/type :mbql/query)))
;;; this should already be a query in the shape we want but:
;; - let's make sure it has the database metadata that was passed in
@@ -320,16 +320,16 @@
(query metadata-providerable x))
(mu/defn query-from-legacy-inner-query :- ::lib.schema/query
- "Create a pMBQL query from a legacy inner query."
+ "Create a MBQL 5 query from a legacy inner query."
[metadata-providerable :- ::lib.schema.metadata/metadata-providerable
database-id :- ::lib.schema.id/database
inner-query :- :map]
(->> (lib.convert/legacy-query-from-inner-query database-id inner-query)
- lib.convert/->pMBQL
+ lib.convert/->mbql5
(query metadata-providerable)))
(defn ->legacy-MBQL
- "Convert the pMBQL `a-query` into a legacy MBQL query."
+ "Convert the MBQL 5 `a-query` into a legacy MBQL query."
[a-query]
(-> a-query lib.convert/->legacy-MBQL))
diff --git a/src/metabase/lib/schema/common.cljc b/src/metabase/lib/schema/common.cljc
index 823d9b8e8b2..12f4c51ebd1 100644
--- a/src/metabase/lib/schema/common.cljc
+++ b/src/metabase/lib/schema/common.cljc
@@ -63,7 +63,7 @@
(update-keys m memoized-kebab-key)))
(defn normalize-map
- "Base normalization behavior for a pMBQL map: keywordize keys and keywordize `:lib/type`; convert map to
+ "Base normalization behavior for a MBQL 5 map: keywordize keys and keywordize `:lib/type`; convert map to
kebab-case (excluding the so-called [[HORRIBLE-keys]]."
[m]
(-> m normalize-map-no-kebab-case map->kebab-case))
diff --git a/src/metabase/lib/schema/metadata.cljc b/src/metabase/lib/schema/metadata.cljc
index ac4c4bf8f25..b9b27652d8f 100644
--- a/src/metabase/lib/schema/metadata.cljc
+++ b/src/metabase/lib/schema/metadata.cljc
@@ -627,7 +627,7 @@
(mr/def ::card.query
"Saved query. This is possibly still a legacy query, but should already be normalized.
- Call [[metabase.lib.convert/->pMBQL]] on it as needed."
+ Call [[metabase.lib.convert/->mbql5]] on it as needed."
[:map
{:decode/normalize normalize-card-query}])
@@ -660,7 +660,7 @@
(mr/def ::card
"Schema for metadata about a specific Saved Question (which may or may not be a Model). More or less the same as
a [[metabase.queries.models.card]], but with kebab-case keys. Note that the `:dataset-query` is not necessarily
- converted to pMBQL yet. Probably safe to assume it is normalized however. Likewise, `:result-metadata` is probably
+ converted to MBQL 5 yet. Probably safe to assume it is normalized however. Likewise, `:result-metadata` is probably
not quite massaged into a sequence of [[::column]] metadata just yet.
See [[metabase.lib.card/card-metadata-columns]] that converts these as needed."
@@ -705,7 +705,7 @@
[:name ::lib.schema.common/non-blank-string]
[:table-id ::lib.schema.id/table]
;; the MBQL snippet defining this Segment; this may still be in legacy
- ;; format. [[metabase.lib.segment/segment-definition]] handles conversion to pMBQL if needed.
+ ;; format. [[metabase.lib.segment/segment-definition]] handles conversion to MBQL 5 if needed.
[:definition [:maybe :map]]
[:description {:optional true} [:maybe ::lib.schema.common/non-blank-string]]])
@@ -795,7 +795,7 @@
[:ref :metabase.lib.metadata.protocols/metadata-providerable])
(mr/def ::stage
- "Metadata about the columns returned by a particular stage of a pMBQL query. For example a single-stage native query
+ "Metadata about the columns returned by a particular stage of a MBQL 5 query. For example a single-stage native query
like
{:database 1
diff --git a/src/metabase/lib_metric/ast/build.cljc b/src/metabase/lib_metric/ast/build.cljc
index 1212a948e2e..e848246d094 100644
--- a/src/metabase/lib_metric/ast/build.cljc
+++ b/src/metabase/lib_metric/ast/build.cljc
@@ -10,8 +10,8 @@
;;; -------------------- Helper Functions --------------------
-(defn- ensure-pmbql
- "Ensure query is in pMBQL format. Converts legacy MBQL if needed."
+(defn- ensure-mbql5
+ "Ensure query is in MBQL 5 format. Converts legacy MBQL if needed."
[metadata-provider mbql-query]
(lib/query metadata-provider mbql-query))
@@ -288,35 +288,35 @@
:clause mbql-clause})
(defn- extract-source-filters
- "Extract filters from pMBQL query and convert to AST filter node.
+ "Extract filters from MBQL 5 query and convert to AST filter node.
Returns nil if no filters, a single filter/mbql node if one filter,
or a filter/and node containing filter/mbql nodes if multiple."
- [pmbql-query]
- (when-let [filters (lib/filters pmbql-query 0)]
+ [mbql5-query]
+ (when-let [filters (lib/filters mbql5-query 0)]
(if (= 1 (count filters))
(mbql-clause->filter-mbql-node (first filters))
{:node/type :filter/and
:children (perf/mapv mbql-clause->filter-mbql-node filters)})))
(defn- extract-source-joins
- "Extract joins from pMBQL query and convert to AST join nodes."
- [pmbql-query]
- (when-let [joins (lib/joins pmbql-query 0)]
+ "Extract joins from MBQL 5 query and convert to AST join nodes."
+ [mbql5-query]
+ (when-let [joins (lib/joins mbql5-query 0)]
(perf/mapv (fn [join]
{:node/type :ast/join
:mbql-join join})
joins)))
-(defn- pmbql-query->source-node
- "Parse pMBQL query into source node structure using lib functions.
+(defn- mbql5-query->source-node
+ "Parse MBQL 5 query into source node structure using lib functions.
For source-card queries (metrics based on models or saved questions),
falls back to the table-id from the entity metadata."
- [source-type id metadata pmbql-query]
- (let [table-id (or (lib.util/source-table-id pmbql-query)
+ [source-type id metadata mbql5-query]
+ (let [table-id (or (lib.util/source-table-id mbql5-query)
(:table-id metadata))
- aggregation (first (lib/aggregations pmbql-query 0))
- source-filter (extract-source-filters pmbql-query)
- source-joins (extract-source-joins pmbql-query)]
+ aggregation (first (lib/aggregations mbql5-query 0))
+ source-filter (extract-source-filters mbql5-query)
+ source-joins (extract-source-joins mbql5-query)]
(cond-> {:node/type source-type
:id id
:name (:name metadata)
@@ -356,7 +356,7 @@
(defn from-definition
"Create complete AST from MetricDefinition.
- Converts legacy MBQL to pMBQL before processing.
+ Converts legacy MBQL to MBQL 5 before processing.
Metadata is loaded from the provider using the expression leaf's type and ID.
Dimensions and dimension-mappings are loaded from the fetched metadata."
@@ -380,7 +380,7 @@
raw-query (case leaf-type
:metric (:dataset-query metadata)
:measure (:definition metadata))
- pmbql-query (ensure-pmbql metadata-provider raw-query)
+ mbql5-query (ensure-mbql5 metadata-provider raw-query)
;; Extract flat filters for this leaf's UUID
leaf-filters (into []
(comp (filter #(= leaf-uuid (:lib/uuid %)))
@@ -394,7 +394,7 @@
ast-filter (when (seq leaf-filters) (mbql-filters->ast-filter leaf-filters))
ast-group-by (when (seq leaf-projections) (perf/mapv dimension-ref->ast-dimension-ref leaf-projections))]
{:node/type :ast/root
- :source (pmbql-query->source-node source-type leaf-id metadata pmbql-query)
+ :source (mbql5-query->source-node source-type leaf-id metadata mbql5-query)
:dimensions (perf/mapv dimension-node (or dimensions []))
:mappings (perf/mapv dimension-mapping-node (or dimension-mappings []))
:filter ast-filter
diff --git a/src/metabase/lib_metric/ast/compile.cljc b/src/metabase/lib_metric/ast/compile.cljc
index 891ec442985..394b3868ff8 100644
--- a/src/metabase/lib_metric/ast/compile.cljc
+++ b/src/metabase/lib_metric/ast/compile.cljc
@@ -168,7 +168,7 @@
(seq (:joins source)))
(defn- compile-join-nodes
- "Compile AST join nodes to pMBQL join clauses.
+ "Compile AST join nodes to MBQL 5 join clauses.
Forces `:fields :all` so that all joined columns are visible in stage 1 of
two-stage queries (the only context that calls this function). The dimension
system advertises all joined columns regardless of the original `:fields`
diff --git a/src/metabase/lib_metric/ast/schema.cljc b/src/metabase/lib_metric/ast/schema.cljc
index 4240f74e8dc..006ce804f04 100644
--- a/src/metabase/lib_metric/ast/schema.cljc
+++ b/src/metabase/lib_metric/ast/schema.cljc
@@ -213,7 +213,7 @@
;;; -------------------- Join Nodes --------------------
(mr/def ::join-node
- "A join from the source metric's query, preserved as raw pMBQL."
+ "A join from the source metric's query, preserved as raw MBQL 5."
[:map
[:node/type [:= :ast/join]]
[:mbql-join :any]])
diff --git a/src/metabase/lib_metric/projection.cljc b/src/metabase/lib_metric/projection.cljc
index e5446430689..cf84cc30efe 100644
--- a/src/metabase/lib_metric/projection.cljc
+++ b/src/metabase/lib_metric/projection.cljc
@@ -337,8 +337,8 @@
raw-query (lib-metric.dimension/dimensionable-query metadata)]
(if-not raw-query
[]
- (let [pmbql-query (lib/query metadata-provider raw-query)
- breakout-clauses (lib/breakouts pmbql-query)
+ (let [mbql5-query (lib/query metadata-provider raw-query)
+ breakout-clauses (lib/breakouts mbql5-query)
breakout-field-ids (into #{}
(keep lib-metric.dimension/dimension-target->field-id)
breakout-clauses)]
diff --git a/src/metabase/metabot/agent/user_context.clj b/src/metabase/metabot/agent/user_context.clj
index 0deebdf4b2f..62be458152b 100644
--- a/src/metabase/metabot/agent/user_context.clj
+++ b/src/metabase/metabot/agent/user_context.clj
@@ -77,12 +77,12 @@
The frontend sends `type: \"adhoc\"` for *both* notebook (MBQL) and native SQL
queries. We distinguish them by inspecting the query: a dataset-query with
- `{:type \"native\"}` (or `:native`) is a native SQL query, as is an MLv2/pMBQL
+ `{:type \"native\"}` (or `:native`) is a native SQL query, as is an MLv2/MBQL 5
query with a single native stage."
[item]
(let [query (:query item)]
(or (= "native" (normalize-context-type (:type query)))
- ;; MLv2/pMBQL: normalize and use lib to detect native queries
+ ;; MLv2/MBQL 5: normalize and use lib to detect native queries
(when (and (map? query) (:database query))
(try
(lib/native-only-query? (lib-be/normalize-query query))
diff --git a/src/metabase/metabot/context.clj b/src/metabase/metabot/context.clj
index 5e969b7ccdd..7ef6a830889 100644
--- a/src/metabase/metabot/context.clj
+++ b/src/metabase/metabot/context.clj
@@ -130,7 +130,7 @@
(defn- mbql-source-table-ids
"Given a context item with an MBQL query, return [database-id [table-id ...]] if it has
- source-table references, or nil otherwise. Handles both MLv2/pMBQL and legacy formats."
+ source-table references, or nil otherwise. Handles both MLv2/MBQL 5 and legacy formats."
[item]
(when (= "adhoc" (:type item))
(let [query (:query item)
diff --git a/src/metabase/metabot/tools/construct.clj b/src/metabase/metabot/tools/construct.clj
index 9f564cd4d7a..34fab60c0cf 100644
--- a/src/metabase/metabot/tools/construct.clj
+++ b/src/metabase/metabot/tools/construct.clj
@@ -251,7 +251,7 @@
(defn- structured->query-data
"Convert tool structured output to a map suitable for [[llm-rep/query->xml]].
- Converts the pMBQL query to legacy MBQL, JSON-encodes it, and wraps result columns."
+ Converts the MBQL 5 query to legacy MBQL, JSON-encodes it, and wraps result columns."
[{:keys [query-id query result-columns]}]
(let [legacy-query (when (and (map? query) (:lib/type query))
#_{:clj-kondo/ignore [:discouraged-var]}
diff --git a/src/metabase/metabot/tools/sql/common.clj b/src/metabase/metabot/tools/sql/common.clj
index ddf90fdec21..7d70d8bbc31 100644
--- a/src/metabase/metabot/tools/sql/common.clj
+++ b/src/metabase/metabot/tools/sql/common.clj
@@ -47,8 +47,8 @@
(defn update-query-sql
"Update a dataset_query map with new SQL content.
Handles both legacy MBQL (`{:type :native, :native {:query ...}}`) and
- pMBQL (`{:stages [{:lib/type :mbql.stage/native, :native ...}]}`) formats,
- including the JSON-serialized pMBQL variant where enum values are strings."
+ MBQL 5 (`{:stages [{:lib/type :mbql.stage/native, :native ...}]}`) formats,
+ including the JSON-serialized MBQL 5 variant where enum values are strings."
[query new-sql]
(let [normalized (maybe-normalize-query query)]
(cond
diff --git a/src/metabase/parameters/custom_values.clj b/src/metabase/parameters/custom_values.clj
index 9c66ef7b9ab..846759cfa13 100644
--- a/src/metabase/parameters/custom_values.clj
+++ b/src/metabase/parameters/custom_values.clj
@@ -135,7 +135,7 @@
query-string :- [:maybe ms/NonBlankString]]
(let [card-id (:card_id config)
card (t2/select-one :model/Card :id card-id)]
- (values-from-card card (lib/->pMBQL (:value_field config)) {:query-string query-string})))
+ (values-from-card card (lib/->mbql5 (:value_field config)) {:query-string query-string})))
(defn- can-get-card-values?
[card value-field]
diff --git a/src/metabase/queries/models/card/metadata.clj b/src/metabase/queries/models/card/metadata.clj
index 0008ded48ee..8fc12faa0af 100644
--- a/src/metabase/queries/models/card/metadata.clj
+++ b/src/metabase/queries/models/card/metadata.clj
@@ -80,7 +80,7 @@ saved later when it is ready."
(defn normalize-dataset-query
"Normalize the query `dataset-query` received via an HTTP call.
- Handles both (legacy) MBQL and pMBQL queries."
+ Handles both (legacy) MBQL and MBQL 5 queries."
{:deprecated "0.57.0"}
[dataset-query]
(lib-be/normalize-query dataset-query))
diff --git a/src/metabase/queries/models/query.clj b/src/metabase/queries/models/query.clj
index 0d6d3d3359a..a9104b806f4 100644
--- a/src/metabase/queries/models/query.clj
+++ b/src/metabase/queries/models/query.clj
@@ -109,7 +109,7 @@
:table-id table-id}))))
(mu/defn query-is-native? :- :boolean
- "Whether this query (pMBQL or legacy) has a `:native` first stage. Queries with source Cards are considered to be MBQL
+ "Whether this query (MBQL 5 or legacy) has a `:native` first stage. Queries with source Cards are considered to be MBQL
regardless of whether the Card has a native query or not."
[query :- [:maybe ::queries.schema/query]]
(boolean (some-> query not-empty lib/native-only-query?)))
diff --git a/src/metabase/query_processor/middleware/annotate.clj b/src/metabase/query_processor/middleware/annotate.clj
index 150eab74e93..441bd042c1f 100644
--- a/src/metabase/query_processor/middleware/annotate.clj
+++ b/src/metabase/query_processor/middleware/annotate.clj
@@ -46,7 +46,7 @@
[:cols {:optional true} ::cols]])
(mu/defn expected-cols :- [:sequential ::qp-results-cased-col]
- "Return metadata for columns returned by a pMBQL `query`.
+ "Return metadata for columns returned by a MBQL 5 `query`.
`initial-cols` are (optionally) the initial minimal metadata columns as returned by the driver (usually just column
name and base type). If provided these are merged with the columns the query is expected to return.
diff --git a/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.clj b/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.clj
index ef37ed0d824..602c6edbf7d 100644
--- a/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.clj
+++ b/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.clj
@@ -18,7 +18,7 @@
[metabase.util.i18n :refer [tru]]
[metabase.util.malli :as mu]))
-(mu/defn legacy-inner-query->mlv2-query :- ::lib.schema/query
+(mu/defn legacy-inner-query->mbql5-query :- ::lib.schema/query
"Convert a legacy `inner-query` to an MLv2 query. Requires bound QP store."
{:deprecated "0.57.0"}
[inner-query :- [:and
@@ -35,7 +35,7 @@
(:id (lib.metadata/database (qp.store/metadata-provider)))
(mbql.normalize/normalize ::mbql.s/MBQLQuery inner-query))
(catch Throwable e
- (throw (ex-info (tru "Error converting query to pMBQL: {0}" (ex-message e))
+ (throw (ex-info (tru "Error converting query to MBQL 5: {0}" (ex-message e))
{:inner-query inner-query, :type qp.error-type/qp}
e))))))
@@ -46,13 +46,13 @@
These names are also used directly in queries, e.g. in the equivalent of a SQL `AS` clause."
[legacy-inner-query :- :map
legacy-ag-clause]
- (let [ag-clause (lib/->pMBQL legacy-ag-clause)]
+ (let [ag-clause (lib/->mbql5 legacy-ag-clause)]
(or (::add/desired-alias (lib/options ag-clause))
(:name (lib/options ag-clause))
(lib/column-name
#_{:clj-kondo/ignore [:deprecated-var]}
- (legacy-inner-query->mlv2-query legacy-inner-query)
- (lib/->pMBQL legacy-ag-clause)))))
+ (legacy-inner-query->mbql5-query legacy-inner-query)
+ (lib/->mbql5 legacy-ag-clause)))))
(mu/defn merged-column-info :- :metabase.query-processor.middleware.annotate/cols
"Returns deduplicated and merged column metadata (`:cols`) for query results by combining (a) the initial results
diff --git a/src/metabase/query_processor/middleware/expand_macros.clj b/src/metabase/query_processor/middleware/expand_macros.clj
index 0c5132e417a..37e92f2159b 100644
--- a/src/metabase/query_processor/middleware/expand_macros.clj
+++ b/src/metabase/query_processor/middleware/expand_macros.clj
@@ -52,11 +52,11 @@
;;; a legacy Segment has one or more filter clauses.
(mu/defn- segment-definition->stage :- ::lib.schema/stage.mbql
- "Extract the pMBQL stage from a segment definition. Segment definitions are always MBQL 5 queries at this point
+ "Extract the MBQL 5 stage from a segment definition. Segment definitions are always MBQL 5 queries at this point
(converted by the segment model's after-select hook), so we just extract the first stage."
[_metadata-providerable :- ::lib.schema.metadata/metadata-providerable
{:keys [definition], :as _legacy-macro} :- ::legacy-macro]
- (log/tracef "Extracting pMBQL stage from segment definition:\n%s" (u/pprint-to-str definition))
+ (log/tracef "Extracting MBQL 5 stage from segment definition:\n%s" (u/pprint-to-str definition))
(u/prog1 (first (:stages definition))
(log/tracef "Extracted stage:\n%s" (u/pprint-to-str <>))))
diff --git a/src/metabase/query_processor/middleware/fetch_source_query.clj b/src/metabase/query_processor/middleware/fetch_source_query.clj
index fd0edd7ecd6..27cb177c729 100644
--- a/src/metabase/query_processor/middleware/fetch_source_query.clj
+++ b/src/metabase/query_processor/middleware/fetch_source_query.clj
@@ -43,7 +43,7 @@
(cons first-stage more)))
(mu/defn normalize-card-query :- ::lib.schema.metadata/card
- "Convert Card's query (`:dataset-query`) to pMBQL as needed; splice in stage metadata and some extra keys."
+ "Convert Card's query (`:dataset-query`) to MBQL 5 as needed; splice in stage metadata and some extra keys."
[metadata-providerable :- ::lib.schema.metadata/metadata-providerable
{card-id :id, :as card} :- ::lib.schema.metadata/card]
(let [persisted-info (:lib/persisted-info card)
diff --git a/src/metabase/query_processor/middleware/parameters/mbql.clj b/src/metabase/query_processor/middleware/parameters/mbql.clj
index caf7b59242d..d6efd78839c 100644
--- a/src/metabase/query_processor/middleware/parameters/mbql.clj
+++ b/src/metabase/query_processor/middleware/parameters/mbql.clj
@@ -79,7 +79,7 @@
{param-type :type, param-value :value, target :target, :as param} :- ::lib.schema.parameter/parameter]
(let [a-ref (lib.util.match/match-lite target
[#{:field :expression} & _]
- (lib/->pMBQL &match))]
+ (lib/->mbql5 &match))]
(cond
(params.ops/operator? param-type)
(params.ops/to-clause param)
diff --git a/src/metabase/query_processor/middleware/wrap_value_literals.clj b/src/metabase/query_processor/middleware/wrap_value_literals.clj
index 83b8af8904d..fa1df83c5fc 100644
--- a/src/metabase/query_processor/middleware/wrap_value_literals.clj
+++ b/src/metabase/query_processor/middleware/wrap_value_literals.clj
@@ -321,7 +321,7 @@
{:deprecated "0.57.0"}
[mbql :- [:cat :keyword [:* :any]]]
(-> mbql
- lib/->pMBQL
+ lib/->mbql5
(as-> $mbql (binding [*type-info* (fn [_query _path clause]
#_{:clj-kondo/ignore [:deprecated-var]}
(type-info-no-query clause))]
diff --git a/src/metabase/query_processor/parameters/operators.clj b/src/metabase/query_processor/parameters/operators.clj
index 68d8c114818..911181775d5 100644
--- a/src/metabase/query_processor/parameters/operators.clj
+++ b/src/metabase/query_processor/parameters/operators.clj
@@ -82,7 +82,7 @@
(let [{param-type :type, [a b :as param-value] :value, target :target, options :options} (normalize-param param)
field-ref (or (lib.util.match/match-lite target
[#{:field :expression} & _]
- (lib/->pMBQL &match))
+ (lib/->mbql5 &match))
(throw (ex-info (format "Invalid target: expected :field ref, got: %s" (pr-str target))
{:target target, :type qp.error-type/invalid-parameter})))
options (or options {})]
diff --git a/src/metabase/query_processor/schema.clj b/src/metabase/query_processor/schema.clj
index 2a5ed813b46..de6440454dd 100644
--- a/src/metabase/query_processor/schema.clj
+++ b/src/metabase/query_processor/schema.clj
@@ -13,7 +13,7 @@
"Schema for a map that is in the general shape of either a legacy MBQL or MBQL 5 query. Query may not be normalized
yet!
- This schema is not very strict because we need to handle different types of queries (legacy MBQL, pMBQL,
+ This schema is not very strict because we need to handle different types of queries (legacy MBQL, MBQL 5,
super-legacy MBQL, internal audit app queries, etc.) and it might not be normalized yet."
[:and
[:map
diff --git a/src/metabase/query_processor/util/add_alias_info.clj b/src/metabase/query_processor/util/add_alias_info.clj
index a516a77a2e1..41d8b34ffc1 100644
--- a/src/metabase/query_processor/util/add_alias_info.clj
+++ b/src/metabase/query_processor/util/add_alias_info.clj
@@ -560,7 +560,7 @@
((some-fn :source-table :source-query) query)
(-> query
#_{:clj-kondo/ignore [:deprecated-var]}
- annotate.legacy-helper-fns/legacy-inner-query->mlv2-query
+ annotate.legacy-helper-fns/legacy-inner-query->mbql5-query
(add-alias-info options)
lib/->legacy-MBQL
:query)
diff --git a/src/metabase/source_swap/native.clj b/src/metabase/source_swap/native.clj
index b302e719fe6..08ea6bcd1cf 100644
--- a/src/metabase/source_swap/native.clj
+++ b/src/metabase/source_swap/native.clj
@@ -267,7 +267,7 @@
- Table template tags (:type :table with :table-id)
Parameters:
- - query: pMBQL query with native stage
+ - query: MBQL 5 query with native stage
- old-table-id: ID of table to replace
- new-table-id: ID of replacement table"
[query old-table-id new-table-id]
@@ -302,7 +302,7 @@
E.g., `FROM {{my_table}}` → `FROM {{#123-my-card}}`
Parameters:
- - query: pMBQL query with native stage
+ - query: MBQL 5 query with native stage
- old-table-id: ID of table to replace
- new-card-id: ID of card to reference"
[query old-table-id new-card-id]
@@ -367,7 +367,7 @@
This is the inverse of `replace-table-with-card-in-native`.
Parameters:
- - query: pMBQL query with native stage
+ - query: MBQL 5 query with native stage
- old-card-id: ID of card template tag to replace
- new-table-id: ID of table to reference directly"
[query old-card-id new-table-id]
diff --git a/src/metabase/tiles/api.clj b/src/metabase/tiles/api.clj
index 8d96ae09c4c..c34cdae103a 100644
--- a/src/metabase/tiles/api.clj
+++ b/src/metabase/tiles/api.clj
@@ -151,7 +151,7 @@
(mu/defn- resolve-field :- ::lib.schema.metadata/column
[query :- ::lib.schema/query
legacy-ref :- ::legacy-ref]
- (lib/metadata query (lib/->pMBQL legacy-ref)))
+ (lib/metadata query (lib/->mbql5 legacy-ref)))
(mu/defn- tiles-query :- ::lib.schema/query
"Transform a card's query into a query finding coordinates in a particular region.
diff --git a/src/metabase/xrays/automagic_dashboards/schema.clj b/src/metabase/xrays/automagic_dashboards/schema.clj
index 36bdd185f76..24208027b9f 100644
--- a/src/metabase/xrays/automagic_dashboards/schema.clj
+++ b/src/metabase/xrays/automagic_dashboards/schema.clj
@@ -30,7 +30,7 @@
(when (sequential? x)
(if (map? (second x))
x
- (lib/->pMBQL x))))}
+ (lib/->mbql5 x))))}
[:ref ::lib.schema.mbql-clause/clause]
[:ref ::lib.schema.expression/boolean]])
diff --git a/test/metabase/lib/aggregation_test.cljc b/test/metabase/lib/aggregation_test.cljc
index d32334ad7e2..67d9d4d0eeb 100644
--- a/test/metabase/lib/aggregation_test.cljc
+++ b/test/metabase/lib/aggregation_test.cljc
@@ -113,7 +113,7 @@
;;; make sure that given an existing query, the expected description was generated correctly.
(defn- describe-legacy-query [query]
- (lib/describe-query (lib.query/query meta/metadata-provider (lib.convert/->pMBQL query))))
+ (lib/describe-query (lib.query/query meta/metadata-provider (lib.convert/->mbql5 query))))
(deftest ^:parallel describe-multiple-aggregations-test
(let [query {:database (meta/id)
@@ -802,7 +802,7 @@
(lib/expression "Zero" (lib/+ 0 0))
(lib/expression "Total of Zero" (lib/coalesce (meta/field-metadata :orders :total) 0)))
converted-query (lib/query meta/metadata-provider
- (lib.convert/->pMBQL
+ (lib.convert/->mbql5
(lib.tu.macros/mbql-query orders
{:expressions {"Zero" [:+ 0 0]
"Total of Zero" [:coalesce $total 0]}})))
diff --git a/test/metabase/lib/convert_test.cljc b/test/metabase/lib/convert_test.cljc
index da8c803c731..0983320e94a 100644
--- a/test/metabase/lib/convert_test.cljc
+++ b/test/metabase/lib/convert_test.cljc
@@ -15,7 +15,7 @@
#?(:cljs (comment metabase.test-runner.assert-exprs.approximately-equal/keep-me))
-(deftest ^:parallel ->pMBQL-test
+(deftest ^:parallel ->mbql5-test
(is (=? {:lib/type :mbql/query
:stages [{:lib/type :mbql.stage/mbql
:source-table 1}
@@ -24,7 +24,7 @@
[:field {:lib/uuid string?, :temporal-unit :month} 3]]
:aggregation [[:count {:lib/uuid string?}]]}]
:database 1}
- (lib.convert/->pMBQL
+ (lib.convert/->mbql5
{:database 1
:type :query
:query {:source-query {:source-table 1}
@@ -33,11 +33,11 @@
:aggregation [[:count]]}})))
(testing ":field clause"
(are [clause expected] (=? expected
- (lib.convert/->pMBQL clause))
+ (lib.convert/->mbql5 clause))
[:field 2 nil] [:field {:lib/uuid string?} 2]
[:field 3 {:temporal-unit :month}] [:field {:lib/uuid string?, :temporal-unit :month} 3])))
-(deftest ^:parallel ->pMBQL-idempotency-test
+(deftest ^:parallel ->mbql5-idempotency-test
(is (=? {:lib/type :mbql/query
:stages [{:lib/type :mbql.stage/mbql
:source-table 1}
@@ -46,8 +46,8 @@
[:field {:lib/uuid string?, :temporal-unit :month} 3]]
:aggregation [[:count {:lib/uuid string?}]]}]
:database 1}
- (lib.convert/->pMBQL
- (lib.convert/->pMBQL
+ (lib.convert/->mbql5
+ (lib.convert/->mbql5
{:database 1
:type :query
:query {:source-query {:source-table 1}
@@ -55,15 +55,15 @@
[:field 3 {:temporal-unit :month}]]
:aggregation [[:count]]}})))))
-(deftest ^:parallel ->pMBQL-idempotency-test-2
+(deftest ^:parallel ->mbql5-idempotency-test-2
(testing ":field clause"
(are [clause expected] (=? expected
- (lib.convert/->pMBQL (lib.convert/->pMBQL clause)))
+ (lib.convert/->mbql5 (lib.convert/->mbql5 clause)))
[:field 2 nil] [:field {:lib/uuid string?} 2]
[:field 3 {:temporal-unit :month}] [:field {:lib/uuid string?, :temporal-unit :month} 3])))
-(deftest ^:parallel ->pMBQL-idempotency-test-3
- (testing "Calling ->pMBQL on something already MBQL 5 should no-op instead of adding duplicate options maps"
+(deftest ^:parallel ->mbql5-idempotency-test-3
+ (testing "Calling ->mbql5 on something already MBQL 5 should no-op instead of adding duplicate options maps"
(let [clause [[:=
{:lib/uuid "1cb124b0-757f-4717-b8ee-9cf12a7c3f62"}
[:field
@@ -75,9 +75,9 @@
:lib/uuid "b23a769d-774a-4eb5-8fb8-1f6a33c9a8d5"}
"USER_ID"]]]]
(is (= clause
- (lib.convert/->pMBQL clause))))))
+ (lib.convert/->mbql5 clause))))))
-(deftest ^:parallel ->pMBQL-joins-test
+(deftest ^:parallel ->mbql5-joins-test
(is (=? {:lib/type :mbql/query
:database (meta/id)
:stages [{:lib/type :mbql.stage/mbql
@@ -99,7 +99,7 @@
:fk-field-id (meta/id :venues :category-id)
:stages [{:lib/type :mbql.stage/mbql
:source-table (meta/id :venues)}]}]}]}
- (lib.convert/->pMBQL
+ (lib.convert/->mbql5
{:database (meta/id)
:type :query
:query {:source-table (meta/id :categories)
@@ -112,7 +112,7 @@
:strategy :left-join
:fk-field-id (meta/id :venues :category-id)}]}}))))
-(deftest ^:parallel ->pMBQL-native-query-test
+(deftest ^:parallel ->mbql5-native-query-test
(testing "template tag dimensions are converted"
(let [original {:type :native
:native
@@ -126,12 +126,12 @@
:widget-type :string/=
:default nil}}}
:database 76}
- converted (lib.convert/->pMBQL original)]
+ converted (lib.convert/->mbql5 original)]
(is (=? {:stages [{:template-tags {"NAME" {:dimension [:field {:lib/uuid string?} 866]}}}]}
converted))
(is (mr/validate :metabase.lib.schema/query converted)))))
-(deftest ^:parallel ->pMBQL-joins-default-alias-test
+(deftest ^:parallel ->mbql5-joins-default-alias-test
(let [original {:database (meta/id)
:type :query
:query {:source-table (meta/id :categories)
@@ -176,11 +176,11 @@
:strategy :left-join
:stages [{:lib/type :mbql.stage/mbql
:source-table (meta/id :checkins)}]}]}]}
- (lib.convert/->pMBQL original)))
+ (lib.convert/->mbql5 original)))
(is (= original
- (-> original lib.convert/->pMBQL lib.convert/->legacy-MBQL)))))
+ (-> original lib.convert/->mbql5 lib.convert/->legacy-MBQL)))))
-(deftest ^:parallel ->pMBQL-join-fields-test
+(deftest ^:parallel ->mbql5-join-fields-test
(testing "#29898"
(is (=? {:lib/type :mbql/query
:stages [{:lib/type :mbql.stage/mbql
@@ -197,7 +197,7 @@
:limit 1
:source-table 4}]
:database 5}
- (lib.convert/->pMBQL
+ (lib.convert/->mbql5
{:database 5
:type :query
:query {:joins [{:source-table 3
@@ -214,7 +214,7 @@
:aggregation [[:sum
{:lib/uuid string?, :display-name "Revenue"}
[:field {:lib/uuid string?} 1]]]}]}
- (lib.convert/->pMBQL {:type :query
+ (lib.convert/->mbql5 {:type :query
:database 5
:query {:source-table 1
:aggregation [[:aggregation-options
@@ -244,11 +244,11 @@
(doseq [tag [:contains :starts-with :ends-with :does-not-contain]]
(testing (str tag)
(testing "with two arguments (legacy style)"
- (testing "->pMBQL"
+ (testing "->mbql5"
(is (=? [tag {:lib/uuid string?} [:field {} 12] "ABC"]
- (lib.convert/->pMBQL [tag [:field 12 nil] "ABC"])))
+ (lib.convert/->mbql5 [tag [:field 12 nil] "ABC"])))
(is (=? [tag {:lib/uuid string?, :case-sensitive false} [:field {} 12] "ABC"]
- (lib.convert/->pMBQL [tag [:field 12 nil] "ABC" {:case-sensitive false}]))))
+ (lib.convert/->mbql5 [tag [:field 12 nil] "ABC" {:case-sensitive false}]))))
(testing "->legacy-MBQL"
(is (=? [tag [:field 12 nil] "ABC"]
(lib.convert/->legacy-MBQL [tag {} [:field {} 12] "ABC"])))
@@ -256,13 +256,13 @@
(lib.convert/->legacy-MBQL
(lib.options/ensure-uuid [tag {:case-sensitive false} [:field {} 12] "ABC"]))))))
- (testing "with multiple arguments (pMBQL style)"
- (testing "->pMBQL"
+ (testing "with multiple arguments (MBQL 5 style)"
+ (testing "->mbql5"
(is (=? [tag {:lib/uuid string?} [:field {} 12] "ABC" "HJK" "XYZ"]
- (lib.convert/->pMBQL [tag {} [:field 12 nil] "ABC" "HJK" "XYZ"])))
+ (lib.convert/->mbql5 [tag {} [:field 12 nil] "ABC" "HJK" "XYZ"])))
(is (=? [tag {:lib/uuid string?, :case-sensitive false}
[:field {} 12] "ABC" "HJK" "XYZ"]
- (lib.convert/->pMBQL [tag {:case-sensitive false}
+ (lib.convert/->mbql5 [tag {:case-sensitive false}
[:field 12 nil] "ABC" "HJK" "XYZ"]))))
(testing "->legacy-MBQL"
@@ -280,13 +280,13 @@
:database 1
:stages [{:lib/type :mbql.stage/mbql
:source-card 100}]}
- (lib.convert/->pMBQL original)))
+ (lib.convert/->mbql5 original)))
(is (= original
- (lib.convert/->legacy-MBQL (lib.convert/->pMBQL original))))))
+ (lib.convert/->legacy-MBQL (lib.convert/->mbql5 original))))))
(defn- test-round-trip [x]
(testing (str "original =\n" (u/pprint-to-str x))
- (let [converted (lib.convert/->pMBQL x)]
+ (let [converted (lib.convert/->mbql5 x)]
(testing (str "\nMBQL 5 =\n" (u/pprint-to-str converted))
(is (= x
(lib.convert/->legacy-MBQL converted)))))))
@@ -755,7 +755,7 @@
(deftest ^:parallel round-trip-options-test
(testing "Round-tripping (p)MBQL caluses with options (#30280)"
- (testing "starting with pMBQL"
+ (testing "starting with MBQL 5"
(is (=? [:does-not-contain {:lib/uuid string?
:case-sensitive false}
[:field {:lib/uuid string?} 23]
@@ -764,11 +764,11 @@
:case-sensitive false}
[:field {:lib/uuid "5d01e669-783f-40e0-9ae0-2b8098448390"} 23]
"invite"]
- lib.convert/->legacy-MBQL lib.convert/->pMBQL))))
+ lib.convert/->legacy-MBQL lib.convert/->mbql5))))
(testing "starting with MBQL"
(let [mbql-filter [:does-not-contain [:field 23 nil] "invite" {:case-sensitive false}]]
(is (= mbql-filter
- (-> mbql-filter lib.convert/->pMBQL lib.convert/->legacy-MBQL)))))))
+ (-> mbql-filter lib.convert/->mbql5 lib.convert/->legacy-MBQL)))))))
(deftest ^:parallel case-expression-with-default-value-round-trip-test
(testing "Round trip of case expression with default value (#30280)"
@@ -778,7 +778,7 @@
{:default [:field 13 nil]}]]
{:name "CE"
:display-name "CE"}]
- expected-pmbql-aggregation-options-clause
+ expected-mbql5-aggregation-options-clause
[:distinct {:name "CE"
:display-name "CE"
:lib/uuid string?}
@@ -797,14 +797,14 @@
:aggregation [aggregation-options-clause]
:breakout [[:field 15 {:temporal-unit :month}]]}}
:parameters []}
- pmbql-aggregation-options-clause
- (lib.convert/->pMBQL aggregation-options-clause)]
- (is (=? expected-pmbql-aggregation-options-clause
- pmbql-aggregation-options-clause))
+ mbql5-aggregation-options-clause
+ (lib.convert/->mbql5 aggregation-options-clause)]
+ (is (=? expected-mbql5-aggregation-options-clause
+ mbql5-aggregation-options-clause))
(is (=? aggregation-options-clause
- (lib.convert/->legacy-MBQL pmbql-aggregation-options-clause)))
+ (lib.convert/->legacy-MBQL mbql5-aggregation-options-clause)))
(is (= (dissoc mbql-query :parameters)
- (-> mbql-query lib.convert/->pMBQL lib.convert/->legacy-MBQL))))))
+ (-> mbql-query lib.convert/->mbql5 lib.convert/->legacy-MBQL))))))
(deftest ^:parallel round-trip-preserve-metadata-test
(testing "Round-tripping should not affect embedded metadata"
@@ -842,7 +842,7 @@
:percent-state 0.0
:average-length 6.375}}}}]}]
(is (= query
- (-> query lib.convert/->pMBQL lib.convert/->legacy-MBQL))))))
+ (-> query lib.convert/->mbql5 lib.convert/->legacy-MBQL))))))
(deftest ^:parallel value-test
(testing "For some crazy person reason legacy `:value` has `snake_case` options."
@@ -853,8 +853,8 @@
:database_type "INTEGER"
:name "QUANTITY"
:unit :quarter}]
- pMBQL (lib.convert/->pMBQL original)]
- (testing "Normalize keys when converting to pMBQL. Add `:effective-type`."
+ mbql5 (lib.convert/->mbql5 original)]
+ (testing "Normalize keys when converting to mbql5. Add `:effective-type`."
(is (=? [:value
{:lib/uuid string?
:effective-type :type/Integer
@@ -864,18 +864,18 @@
:name "QUANTITY"
:unit :quarter}
3]
- pMBQL)))
+ mbql5)))
(testing "Round trip: make sure we convert back to `snake_case` when converting back."
(is (= original
- (lib.convert/->legacy-MBQL pMBQL))))))
+ (lib.convert/->legacy-MBQL mbql5))))))
(testing "Type is filled in properly when missing"
(is (=? [:value {:effective-type :type/Text} "TX"]
- (lib.convert/->pMBQL [:value "TX" nil])))))
+ (lib.convert/->mbql5 [:value "TX" nil])))))
(deftest ^:parallel clean-test
;; These nearly-empty queries should be handled correctly - iframe-based embedding yields queries like
;; `{:type :native}` and nothing more.
- (are [query] (= query (-> query lib.convert/->pMBQL lib.convert/->legacy-MBQL))
+ (are [query] (= query (-> query lib.convert/->mbql5 lib.convert/->legacy-MBQL))
{:type :query
:database 1}
{:type :query
@@ -886,13 +886,13 @@
:type :query
:query {:source-table 224
:order-by [[:asc [:xfield 1 nil]]]}}
- lib.convert/->pMBQL
+ lib.convert/->mbql5
lib/order-bys)))
(is (nil? (-> {:database 1
:type :query
:query {:source-table 224
:filter [:and [:= [:xfield 1 nil]]]}}
- lib.convert/->pMBQL
+ lib.convert/->mbql5
lib/filters)))
(is (nil? (-> {:database 5
:type :query
@@ -900,7 +900,7 @@
;; Invalid condition makes the join invalid
:condition [:= [:field 2 nil] [:xfield 2 nil]]}]
:source-table 4}}
- lib.convert/->pMBQL
+ lib.convert/->mbql5
lib/joins)))
(is (nil? (-> {:database 5
:type :query
@@ -909,7 +909,7 @@
;; Invalid field, the join is still valid
:fields [[:xfield 2 nil]]}]
:source-table 4}}
- lib.convert/->pMBQL
+ lib.convert/->mbql5
(get-in [:stages 0 :joins 0 :fields]))))
(testing "references to missing expressions are removed (#32625)"
(let [query {:database 2762
@@ -920,7 +920,7 @@
:order-by [[:expression "expr2" nil]]
:limit 4
:source-table 33674}}
- converted (lib.convert/->pMBQL query)]
+ converted (lib.convert/->mbql5 query)]
(is (empty? (get-in converted [:stages 0 :breakout])))
(is (empty? (get-in converted [:stages 0 :group-by]))))))
@@ -945,7 +945,7 @@
(lib/with-join-alias "O")
lib/ref
(lib/with-temporal-bucket :year)))]))))]
- (testing "sanity check: the pMBQL query should namespaced have keys (:lib/original-effective-type)"
+ (testing "sanity check: the MBQL 5 query should namespaced have keys (:lib/original-effective-type)"
(is (=? {:stages [{:joins [{:alias "O"
:conditions [[:=
{}
@@ -974,9 +974,9 @@
:lib/original-effective-type (symbol "nil #_\"key is not present.\"")}]]}]}}
(lib.convert/->legacy-MBQL query)))))))
-(deftest ^:parallel legacy-ref->pMBQL-field-test
+(deftest ^:parallel legacy-ref->mbql5-field-test
(are [legacy-ref] (=? [:field {:lib/uuid string?} (meta/id :venues :name)]
- (lib.convert/legacy-ref->pMBQL (lib.tu/venues-query) legacy-ref))
+ (lib.convert/legacy-ref->mbql5 (lib.tu/venues-query) legacy-ref))
[:field (meta/id :venues :name) nil]
[:field (meta/id :venues :name) {}]
;; should work with refs that need normalization
@@ -987,13 +987,13 @@
#js ["field" (meta/id :venues :name) #js {}]]))
#?(:cljs
(is (=? [:field {:base-type :type/Integer, :lib/uuid string?} (meta/id :venues :name)]
- (lib.convert/legacy-ref->pMBQL
+ (lib.convert/legacy-ref->mbql5
(lib.tu/venues-query)
#js ["field" (meta/id :venues :name) #js {"base-type" "type/Integer"}])))))
-(deftest ^:parallel legacy-ref->pMBQL-expression-test
+(deftest ^:parallel legacy-ref->mbql5-expression-test
(are [legacy-ref] (=? [:expression {:lib/uuid string?} "expr"]
- (lib.convert/legacy-ref->pMBQL (lib.tu/query-with-expression) legacy-ref))
+ (lib.convert/legacy-ref->mbql5 (lib.tu/query-with-expression) legacy-ref))
[:expression "expr"]
["expression" "expr"]
["expression" "expr" nil]
@@ -1002,12 +1002,12 @@
[#js ["expression" "expr"]
#js ["expression" "expr" #js {}]])))
-(deftest ^:parallel legacy-ref->pMBQL-aggregation-test
+(deftest ^:parallel legacy-ref->mbql5-aggregation-test
(let [query (-> (lib.tu/venues-query)
(lib/aggregate (lib/count)))
[ag] (lib/aggregations query)]
(are [legacy-ref] (=? [:aggregation {:lib/uuid string?} (lib.options/uuid ag)]
- (lib.convert/legacy-ref->pMBQL query legacy-ref))
+ (lib.convert/legacy-ref->mbql5 query legacy-ref))
[:aggregation 0]
["aggregation" 0]
["aggregation" 0 nil]
@@ -1017,7 +1017,7 @@
#js ["aggregation" 0 #js {}]]))))
(deftest ^:parallel convert-aggregation-reference-test
- (testing "Don't wrap :aggregation in :aggregation options when converting between legacy and pMBQL"
+ (testing "Don't wrap :aggregation in :aggregation options when converting between legacy and MBQL 5"
(let [query {:database 2
:type :query
:query {:aggregation [[:aggregation-options
@@ -1031,27 +1031,27 @@
:position 0}]]]
:source-table 12}}]
(is (= query
- (-> query lib.convert/->pMBQL lib.convert/->legacy-MBQL))))))
+ (-> query lib.convert/->mbql5 lib.convert/->legacy-MBQL))))))
(deftest ^:parallel parameters-dimension-clause-test
(testing "Don't convert :template-tag clauses... YET"
- (let [pmbql (lib.convert/->pMBQL {:database 1
+ (let [mbql5 (lib.convert/->mbql5 {:database 1
:type :native
:native {:parameters [{:target [:dimension [:template-tag "x"]]}]}})]
(is (=? {:stages [{:parameters [{:target [:dimension [:template-tag "x"]]}]}]}
- pmbql))
+ mbql5))
(is (=? {:native {:parameters [{:target [:dimension [:template-tag "x"]]}]}}
- (lib.convert/->legacy-MBQL pmbql))))))
+ (lib.convert/->legacy-MBQL mbql5))))))
(deftest ^:parallel parameters-field-target-test
(testing "Don't convert :field clauses inside :parameters... YET"
- (let [pmbql (lib.convert/->pMBQL {:database 1
+ (let [mbql5 (lib.convert/->mbql5 {:database 1
:type :native
:native {:parameters [{:target [:field 1 nil]}]}})]
(is (=? {:stages [{:parameters [{:target [:field 1 nil]}]}]}
- pmbql))
+ mbql5))
(is (=? {:native {:parameters [{:target [:field 1 nil]}]}}
- (lib.convert/->legacy-MBQL pmbql))))))
+ (lib.convert/->legacy-MBQL mbql5))))))
(deftest ^:parallel time-interval-nil-options-test
(testing "We should convert :time-interval clauses with nil options correctly"
@@ -1060,7 +1060,7 @@
[:field {:lib/uuid string?} 1]
-5
:year]
- (lib/->pMBQL x))
+ (lib/->mbql5 x))
[:time-interval [:field 1 nil] -5 :year nil]
[:time-interval [:field 1 nil] -5 :year {}])))
@@ -1087,7 +1087,7 @@
[:interval {} 1 :year]]
[:relative-datetime {} -2 :month]
[:relative-datetime {} 0 :month]]]}]}
- (lib.convert/->pMBQL legacy))))))
+ (lib.convert/->mbql5 legacy))))))
(deftest ^:parallel offset-test
(testing "Preserve complete options map when converting :offset to legacy, do not wrap in aggregation-options"
@@ -1180,14 +1180,14 @@
:display-name "ID"}]}}]
:lib/stage-metadata (symbol "nil #_\"key is not present.\"")
:source-metadata (symbol "nil #_\"key is not present.\"")}]}]}
- (-> legacy lib.convert/->pMBQL))))
+ (-> legacy lib.convert/->mbql5))))
(testing "legacy => MBQL 5 => legacy"
(is (=? {:query {:joins [{:alias "CATEGORIES__via__CATEGORY_ID"
:source-metadata [{:lib/type (symbol "nil #_\"key is not present.\"")
:name "ID"
:display_name "ID"
:base_type :type/Integer}]}]}}
- (-> legacy lib.convert/->pMBQL lib.convert/->legacy-MBQL))))
+ (-> legacy lib.convert/->mbql5 lib.convert/->legacy-MBQL))))
(testing "legacy => MBQL 5 => legacy => MBQL 5"
(is (=? {:stages [{:joins [{:lib/type :mbql/join
:stages [{:lib/stage-metadata {:lib/type :metadata/results
@@ -1196,39 +1196,39 @@
:display-name "ID"}]}}]
:lib/stage-metadata (symbol "nil #_\"key is not present.\"")
:source-metadata (symbol "nil #_\"key is not present.\"")}]}]}
- (-> legacy lib.convert/->pMBQL lib.convert/->legacy-MBQL lib.convert/->pMBQL)))))))
+ (-> legacy lib.convert/->mbql5 lib.convert/->legacy-MBQL lib.convert/->mbql5)))))))
-(deftest ^:parallel ->pMBQL-datetime-test
+(deftest ^:parallel ->mbql5-datetime-test
(is (=? [:datetime {:mode :unix-seconds
:lib/uuid string?} 10]
- (lib.convert/->pMBQL [:datetime 10 {:mode :unix-seconds}])))
+ (lib.convert/->mbql5 [:datetime 10 {:mode :unix-seconds}])))
(is (=? [:datetime {:mode :iso
:lib/uuid string?} ""]
- (lib.convert/->pMBQL [:datetime "" {:mode :iso}])))
+ (lib.convert/->mbql5 [:datetime "" {:mode :iso}])))
(is (=? [:datetime {:lib/uuid string?} ""]
- (lib.convert/->pMBQL [:datetime "" {}])))
+ (lib.convert/->mbql5 [:datetime "" {}])))
(is (=? [:datetime {:lib/uuid string?} ""]
- (lib.convert/->pMBQL [:datetime ""]))))
+ (lib.convert/->mbql5 [:datetime ""]))))
-(deftest ^:parallel ->pMBQL-relative-datetime-test
- (testing "Convert legacy relative-datetime with string unit to pMBQL with keyword unit"
+(deftest ^:parallel ->mbql5-relative-datetime-test
+ (testing "Convert legacy relative-datetime with string unit to MBQL 5 with keyword unit"
(is (=? [:relative-datetime {:lib/uuid string?} -1 :quarter]
- (lib.convert/->pMBQL [:relative-datetime -1 "quarter"])))
+ (lib.convert/->mbql5 [:relative-datetime -1 "quarter"])))
(is (=? [:relative-datetime {:lib/uuid string?} -1 :month]
- (lib.convert/->pMBQL [:relative-datetime -1 "month"])))
+ (lib.convert/->mbql5 [:relative-datetime -1 "month"])))
(is (=? [:relative-datetime {:lib/uuid string?} 0 :day]
- (lib.convert/->pMBQL [:relative-datetime 0 "day"]))))
- (testing "Convert legacy relative-datetime with keyword unit to pMBQL"
+ (lib.convert/->mbql5 [:relative-datetime 0 "day"]))))
+ (testing "Convert legacy relative-datetime with keyword unit to MBQL 5"
(is (=? [:relative-datetime {:lib/uuid string?} -1 :quarter]
- (lib.convert/->pMBQL [:relative-datetime -1 :quarter]))))
- (testing "Convert legacy relative-datetime without unit to pMBQL"
+ (lib.convert/->mbql5 [:relative-datetime -1 :quarter]))))
+ (testing "Convert legacy relative-datetime without unit to MBQL 5"
(is (=? [:relative-datetime {:lib/uuid string?} -1]
- (lib.convert/->pMBQL [:relative-datetime -1]))))
+ (lib.convert/->mbql5 [:relative-datetime -1]))))
(testing "Convert legacy relative-datetime with :current amount"
(is (=? [:relative-datetime {:lib/uuid string?} :current :month]
- (lib.convert/->pMBQL [:relative-datetime :current "month"])))
+ (lib.convert/->mbql5 [:relative-datetime :current "month"])))
(is (=? [:relative-datetime {:lib/uuid string?} :current]
- (lib.convert/->pMBQL [:relative-datetime :current])))))
+ (lib.convert/->mbql5 [:relative-datetime :current])))))
(deftest ^:parallel ->legacy-MBQL-test
(is (= [:datetime 10 {:mode :unix-seconds}]
@@ -1246,7 +1246,7 @@
query (lib/aggregate query (lib/with-expression-name (lib/* 2 sum) "2*sum"))
legacy-query (lib.convert/->legacy-MBQL query)]
(is (= legacy-query
- (-> legacy-query lib.convert/->pMBQL lib.convert/->legacy-MBQL)))))
+ (-> legacy-query lib.convert/->mbql5 lib.convert/->legacy-MBQL)))))
(deftest ^:parallel join-native-source-query->legacy-test
(testing "join :source-query should rename :query to :native for native stages"
@@ -1298,11 +1298,11 @@
:parameters [{:type :date/range, :value "2019-09-29~2023-09-29", :target [:dimension [:expression "date-column"]]}
{:type :category, :value 1, :target [:dimension [:expression "number-column"]]}]}
{:lib/type :mbql.stage/mbql}]}
- (lib/->pMBQL query)))
+ (lib/->mbql5 query)))
(is (=? query
- (-> query lib/->pMBQL lib/->legacy-MBQL)))))
+ (-> query lib/->mbql5 lib/->legacy-MBQL)))))
-;;; TODO (Cam 8/8/25) -- mentioned in `->pMBQL` for `:mbql/join` but we don't even actually ever attach `:parameters`
+;;; TODO (Cam 8/8/25) -- mentioned in `->mbql5` for `:mbql/join` but we don't even actually ever attach `:parameters`
;;; to a join's top-level IRL, so this not something we ACTUALLY need to support.
(deftest ^:parallel join-parameters-test
(let [query {:database 33001
@@ -1331,7 +1331,7 @@
:target [:field 33101 nil]
:value "BBQ"}]}]}]}]
:database 33001}
- (lib/->pMBQL query)))
+ (lib/->mbql5 query)))
(testing "round-trip to legacy should leave join parameters in the :source-query"
(is (=? {:database 33001
:type :query
@@ -1345,7 +1345,7 @@
:condition [:=
[:field 33402 nil]
[:field 33100 {:join-alias "c"}]]}]}}
- (-> query lib/->pMBQL lib/->legacy-MBQL))))))
+ (-> query lib/->mbql5 lib/->legacy-MBQL))))))
(deftest ^:parallel join-parameters-test-2
(testing "If join has top-level :parameters and its source query has :parameters, splice them together"
@@ -1362,7 +1362,7 @@
:stages [{:parameters [{:name "id", :type :category, :target [:field 33100 nil], :value 5}
{:type :category, :target [:field 33101 nil], :value "BBQ"}]}]
:parameters (symbol "nil #_\"key is not present.\"")}]}]}
- (lib/->pMBQL query))))))
+ (lib/->mbql5 query))))))
(deftest ^:parallel convert-join-with-filters-test
(testing "A join whose sole stage has :filters should get converted to a join with a :source-query (QUE-1566)"
@@ -1502,7 +1502,7 @@
:lib columns
:legacy (#'lib.convert/stage-metadata->legacy-metadata {:columns columns}))))]
(is (=? (assoc-in {:stages [{} {}]} mbql-5-path (expected-shapes :lib))
- (lib.convert/->pMBQL query))))))))))
+ (lib.convert/->mbql5 query))))))))))
(deftest ^:parallel join-with-fields-in-last-stage-to-legacy-test
(testing "converting a join whose last stage has :fields to legacy should not stomp on join :field (QUE-1603)"
@@ -1529,7 +1529,7 @@
;; make sure roundtripping doesn't introduce extra stages.
(-> query
lib.convert/->legacy-MBQL
- lib.convert/->pMBQL
+ lib.convert/->mbql5
lib.convert/->legacy-MBQL))))))
(deftest ^:parallel join-with-fields-in-last-stage-to-legacy-test-2
@@ -1555,7 +1555,7 @@
;; make sure roundtripping doesn't introduce extra stages.
(-> query
lib.convert/->legacy-MBQL
- lib.convert/->pMBQL
+ lib.convert/->mbql5
lib.convert/->legacy-MBQL))))))
(deftest ^:parallel do-not-add-extra-stages-to-join-test
@@ -1564,7 +1564,7 @@
:stages [{:source-table 45050
:fields [[:field {:base-type :type/BigInteger} 45500]
[:field {:base-type :type/Text} 45507]]}]}]}]}
- (lib.convert/->pMBQL {:database 45001
+ (lib.convert/->mbql5 {:database 45001
:type :query
:query {:source-table 45060
:joins [{:strategy :left-join
@@ -1644,7 +1644,7 @@
(is (=? [:dimension
{:stage-number 0, :lib/uuid string?}
[:field {:base-type :type/BigInteger, :lib/uuid string?} 49]]
- (lib.convert/->pMBQL [:dimension [:field 49 {:base-type :type/BigInteger}] {:stage-number 0}]))))
+ (lib.convert/->mbql5 [:dimension [:field 49 {:base-type :type/BigInteger}] {:stage-number 0}]))))
(deftest ^:parallel ->legacy-MBQL-idempotence-test
(let [query {:database 1493
diff --git a/test/metabase/lib/expression_test.cljc b/test/metabase/lib/expression_test.cljc
index 2c3ce6b19d7..6896795b374 100644
--- a/test/metabase/lib/expression_test.cljc
+++ b/test/metabase/lib/expression_test.cljc
@@ -494,7 +494,7 @@
(testing "correct expression are accepted silently"
(are [mode expr] (nil? (lib.expression/diagnose-expression
(lib.tu/venues-query) 0 mode
- (lib.convert/->pMBQL expr)
+ (lib.convert/->mbql5 expr)
#?(:clj nil :cljs js/undefined)))
:expression [:/ [:field 1 nil] 100]
:aggregation [:sum [:field 1 {:base-type :type/Integer}]]
@@ -506,7 +506,7 @@
:friendly true}
(lib.expression/diagnose-expression
(lib.tu/venues-query) 0 mode
- (lib.convert/->pMBQL expr)
+ (lib.convert/->mbql5 expr)
#?(:clj nil :cljs js/undefined)))
:expression [:/ [:field 1 {:base-type :type/Address}] 100] "Types are incompatible: / expects a number as the 1st parameter."
;; To make this test case work, the aggregation schema has to be
@@ -527,7 +527,7 @@
"s" [:+ [:expression "a"] [:expression "b"] [:expression "c"]]
"circular-c" [:+ [:expression "x"] 1]
"non-circular-c" [:+ [:expression "a"] 1]}
- lib.convert/->pMBQL)
+ lib.convert/->mbql5)
query (reduce-kv (fn [query expr-name expr]
(lib/expression query 0 expr-name expr))
(lib.tu/venues-query)
@@ -586,7 +586,7 @@
str-expr [:value "foo" nil]
bool-expr [:value true nil]
diagnose-expr (fn [mode expr]
- (lib.expression/diagnose-expression query 0 mode (lib.convert/->pMBQL expr) nil))]
+ (lib.expression/diagnose-expression query 0 mode (lib.convert/->mbql5 expr) nil))]
(testing "valid literal expressions are accepted"
(are [mode expr] (nil? (diagnose-expr mode expr))
:expression int-expr
@@ -601,7 +601,7 @@
(deftest ^:parallel diagnose-expression-nested-aggregation-test
(let [query (lib/query meta/metadata-provider (meta/table-metadata :orders))
diagnose-expr (fn [expr]
- (lib.expression/diagnose-expression query 0 :aggregation (lib.convert/->pMBQL expr) nil))]
+ (lib.expression/diagnose-expression query 0 :aggregation (lib.convert/->mbql5 expr) nil))]
(testing "valid aggregation expressions are accepted"
(are [expr] (nil? (diagnose-expr expr))
[:avg [:field 1]]
@@ -633,7 +633,7 @@
:friendly true}
(lib.expression/diagnose-expression
(lib.tu/venues-query) 0 :expression
- (lib.convert/->pMBQL expr)
+ (lib.convert/->mbql5 expr)
#?(:clj nil :cljs js/undefined)))
;; basic checks with different types
[:+ 1 true] "Types are incompatible: + expects a number as the 2nd parameter."
diff --git a/test/metabase/lib/js_test.cljs b/test/metabase/lib/js_test.cljs
index 5e19ef5b55a..c8bb38bb783 100644
--- a/test/metabase/lib/js_test.cljs
+++ b/test/metabase/lib/js_test.cljs
@@ -75,7 +75,7 @@
"breakout" #js [#js ["field" 3 nil]]
"expressions" #js {"some_expr" #js ["field" 12 nil]}}}]
(is (lib.js/query= q1 q2))))
- (testing "on pMBQL queries"
+ (testing "on MBQL 5 queries"
(let [q1 (-> (lib/query meta/metadata-provider (meta/table-metadata :orders))
(lib/expression "some_expr" (lib/+ (meta/field-metadata :orders :subtotal) 1))
(lib/aggregate (lib/count))
@@ -519,7 +519,7 @@
"b" [:+ [:expression "a"] [:expression "c"]]
"x" [:+ [:expression "b"] 1]
"s" [:+ [:expression "a"] [:expression "b"] [:expression "c"]]}
- lib.convert/->pMBQL)
+ lib.convert/->mbql5)
query (reduce-kv (fn [query expr-name expr]
(lib/expression query 0 expr-name expr))
(lib.tu/venues-query)
diff --git a/test/metabase/lib/metadata/result_metadata_test.cljc b/test/metabase/lib/metadata/result_metadata_test.cljc
index 80ef1129b12..c38eae5e822 100644
--- a/test/metabase/lib/metadata/result_metadata_test.cljc
+++ b/test/metabase/lib/metadata/result_metadata_test.cljc
@@ -279,7 +279,7 @@
[:or [:> $id 10] [:< $id 20]]
[:not [:> $id 10]]]]
(is (=? {:base-type :type/Boolean}
- (expression-metadata :people "expression" (lib.convert/->pMBQL expression))))))))
+ (expression-metadata :people "expression" (lib.convert/->mbql5 expression))))))))
(deftest ^:parallel converted-timezone-test
(testing "col-info for convert-timezone should have a `converted-timezone` property"
@@ -349,7 +349,7 @@
([query ag-clause]
(let [query (-> query
- (lib/aggregate (lib/->pMBQL ag-clause)))]
+ (lib/aggregate (lib/->mbql5 ag-clause)))]
(-> (column-info query {:cols []})
first))))
@@ -517,7 +517,7 @@
[:sum [:expression "double-price"]])))))))
(defn- infered-col-type [expr]
- (let [metadata (expression-metadata :checkins "expression" (lib.convert/->pMBQL expr))]
+ (let [metadata (expression-metadata :checkins "expression" (lib.convert/->mbql5 expr))]
(select-keys metadata [:base-type :effective-type :semantic-type])))
(defn- expression-type
diff --git a/test/metabase/lib/metadata_test.cljc b/test/metabase/lib/metadata_test.cljc
index 013d0587637..9c7731a72af 100644
--- a/test/metabase/lib/metadata_test.cljc
+++ b/test/metabase/lib/metadata_test.cljc
@@ -72,7 +72,7 @@
(deftest ^:parallel transforms-normalizes-query-test
(testing "transforms (plural) should normalize queries like transform (singular) does"
- (let [;; Create a legacy MBQL query (not pMBQL)
+ (let [;; Create a legacy MBQL query (not MBQL 5)
legacy-query {:database (meta/id)
:type :query
:query {:source-table (meta/id :orders)}}
@@ -86,9 +86,9 @@
{:transforms [transform]})
;; Get the single transform - this normalizes the query
single-transform (lib.metadata/transform mp 1)]
- (testing "transform (singular) normalizes the query to pMBQL"
+ (testing "transform (singular) normalizes the query to MBQL 5"
(is (= :mbql/query (get-in single-transform [:source :query :lib/type]))
- "transform should return a normalized pMBQL query with :lib/type"))
+ "transform should return a normalized MBQL 5 query with :lib/type"))
(testing "transforms (plural) should return the same normalized metadata"
(let [all-transforms (lib.metadata/transforms mp)
first-transform (first all-transforms)]
diff --git a/test/metabase/lib/order_by_test.cljc b/test/metabase/lib/order_by_test.cljc
index f19866ad94d..c0396cf722b 100644
--- a/test/metabase/lib/order_by_test.cljc
+++ b/test/metabase/lib/order_by_test.cljc
@@ -147,7 +147,7 @@
;;; make sure that given an existing query the expected description was generated correctly.
(defn- describe-legacy-query-order-by [query]
- (-> (lib.query/query meta/metadata-provider (lib.convert/->pMBQL query))
+ (-> (lib.query/query meta/metadata-provider (lib.convert/->mbql5 query))
(lib.metadata.calculation/describe-top-level-key -1 :order-by)))
(deftest ^:parallel describe-order-by-test
diff --git a/test/metabase/lib/parameters_test.cljc b/test/metabase/lib/parameters_test.cljc
index 507142bbcba..f0c492cf032 100644
--- a/test/metabase/lib/parameters_test.cljc
+++ b/test/metabase/lib/parameters_test.cljc
@@ -33,12 +33,12 @@
(is (= [:dimension other-ref]
(lib/update-parameter-target-field-ref
[:dimension field-ref]
- (fn [_pmbql-ref] (lib.ref/ref other-col))))))
+ (fn [_mbql5-ref] (lib.ref/ref other-col))))))
(testing "dimension target with options: preserves options"
(is (= [:dimension other-ref {:stage-number 0}]
(lib/update-parameter-target-field-ref
[:dimension field-ref {:stage-number 0}]
- (fn [_pmbql-ref] (lib.ref/ref other-col))))))
+ (fn [_mbql5-ref] (lib.ref/ref other-col))))))
(testing "no field ref: returns target unchanged"
(doseq [target [[:variable [:template-tag "foo"]]
[:dimension [:template-tag "tag"]]]]
@@ -50,5 +50,5 @@
(is (= [:dimension other-ref]
(lib/update-parameter-target-field-ref
[:dimension field-ref]
- (fn [_pmbql-ref extra-col] (lib.ref/ref extra-col))
+ (fn [_mbql5-ref extra-col] (lib.ref/ref extra-col))
other-col))))))
diff --git a/test/metabase/lib/query_test.cljc b/test/metabase/lib/query_test.cljc
index fb1bc680e53..a9418948508 100644
--- a/test/metabase/lib/query_test.cljc
+++ b/test/metabase/lib/query_test.cljc
@@ -74,7 +74,7 @@
:filters [[:= {} [:expression {:base-type :type/Integer :effective-type :type/Integer} "math"] 2]]}]}
(lib/query
meta/metadata-provider
- (lib.convert/->pMBQL {:type :query
+ (lib.convert/->mbql5 {:type :query
:database (meta/id)
:query {:source-table (meta/id :venues)
:expressions {"math" [:+ 1 1]}
@@ -86,7 +86,7 @@
(lib/expression-ref $q "CC"))]))
query (lib/join (lib.tu/venues-query) clause)
;; Make a legacy query but don't put types in :field and :expression
- converted-query (lib.convert/->pMBQL
+ converted-query (lib.convert/->mbql5
(walk/postwalk
(fn [node]
(if (map? node)
@@ -152,7 +152,7 @@
false (mock-db-native-perms nil)))))) ; native-permissions not found on the database
(deftest ^:parallel convert-from-legacy-preserve-info-test
- (testing ":info key should be converted when converting from legacy to pMBQL"
+ (testing ":info key should be converted when converting from legacy to MBQL 5"
(is (=? {:lib/type :mbql/query
:lib/metadata lib.metadata.protocols/cached-metadata-provider?
:database (meta/id)
diff --git a/test/metabase/lib/stage_test.cljc b/test/metabase/lib/stage_test.cljc
index 235e77db326..12489f58548 100644
--- a/test/metabase/lib/stage_test.cljc
+++ b/test/metabase/lib/stage_test.cljc
@@ -724,7 +724,7 @@
nonsense-key (assoc :nonsense-key nonsense-key)
lib-key (assoc :lib/nonsense-key lib-key))
clause [:field (meta/id :people :birth-date) opts]]]
- (testing (pr-str (lib/->pMBQL clause))
+ (testing (pr-str (lib/->mbql5 clause))
(testing `lib/returned-columns
(let [query (lib/query
meta/metadata-provider
diff --git a/test/metabase/lib/test_util.cljc b/test/metabase/lib/test_util.cljc
index 65e20f6bf17..b5a0abf2c11 100644
--- a/test/metabase/lib/test_util.cljc
+++ b/test/metabase/lib/test_util.cljc
@@ -370,7 +370,7 @@
{mbql-query :dataset-query, metadata :result-metadata} :- [:map
[:dataset-query :map]
[:result-metadata [:sequential {:min 1} :map]]]]
- (let [mbql-query (cond-> (assoc (lib.convert/->pMBQL mbql-query)
+ (let [mbql-query (cond-> (assoc (lib.convert/->mbql5 mbql-query)
:lib/metadata (lib.metadata/->metadata-provider metadata-providerable))
metadata
(lib.util/update-query-stage -1 assoc :lib/stage-metadata (lib.util/->stage-metadata (mapv #(dissoc % :id :table-id) metadata))))]
diff --git a/test/metabase/lib/test_util/generators.cljc b/test/metabase/lib/test_util/generators.cljc
index 48e2d412544..0f2abbdc93c 100644
--- a/test/metabase/lib/test_util/generators.cljc
+++ b/test/metabase/lib/test_util/generators.cljc
@@ -106,7 +106,7 @@
(def ^:private ^:dynamic *safe-for-old-refs*
"Controls whether the generators will construct queries with things like multiple joins to the same table, which
- create ambiguous refs in classic pMBQL.
+ create ambiguous refs in classic MBQL 5.
Default to true, ie. safe for the current library.
@@ -134,7 +134,7 @@
;; TODO: Add a schema for the step `[vectors ...]`?
(add-step {:kind :aggregate})
-;; TODO: columns should be specified with :ident, but that isn't available yet. For now, pMBQL refs will do.
+;; TODO: columns should be specified with :ident, but that isn't available yet. For now, MBQL 5 refs will do.
(defmethod run-step* :aggregate [query [_aggregate stage-number agg-clause]]
(lib/aggregate query stage-number agg-clause))
diff --git a/test/metabase/lib/util_test.cljc b/test/metabase/lib/util_test.cljc
index cb687bb5ac9..d808c88b07d 100644
--- a/test/metabase/lib/util_test.cljc
+++ b/test/metabase/lib/util_test.cljc
@@ -51,7 +51,7 @@
:native "SELECT * FROM VENUES;"}]}))
(deftest ^:parallel pipeline-joins-test
- ;; this isn't meant to be 100% correct pMBQL -- `->pipeline` is just supposed to put stuff in the generally correct
+ ;; this isn't meant to be 100% correct MBQL 5 -- `->pipeline` is just supposed to put stuff in the generally correct
;; shape, just to make sure we have `:stages` and stuff looking the way they should. [[metabase.lib.convert]] uses
;; this as part of what it does
(is (=? {:lib/type :mbql/query
diff --git a/test/metabase/lib/walk/util_test.cljc b/test/metabase/lib/walk/util_test.cljc
index 23972bf21d5..61413e8a3bb 100644
--- a/test/metabase/lib/walk/util_test.cljc
+++ b/test/metabase/lib/walk/util_test.cljc
@@ -67,7 +67,7 @@
(is (= #{1000}
(lib/all-source-card-ids (lib/query meta/metadata-provider query))))))
-(deftest ^:parallel all-source-card-ids-pmbql-native-query-template-tags-test
+(deftest ^:parallel all-source-card-ids-mbql5-native-query-template-tags-test
(let [query (lib/query meta/metadata-provider {:lib/type :mbql.stage/native
:native "SELECT *;"
:template-tags {"tag_1" {:name "tag_1"
diff --git a/test/metabase/lib_be/metadata/jvm_test.clj b/test/metabase/lib_be/metadata/jvm_test.clj
index b77dd1b606f..61db5238e78 100644
--- a/test/metabase/lib_be/metadata/jvm_test.clj
+++ b/test/metabase/lib_be/metadata/jvm_test.clj
@@ -55,7 +55,7 @@
&Orders.*sum/Integer]}]
:fields [$id]})
mlv2-query (lib/query (mt/metadata-provider)
- (lib.convert/->pMBQL query))]
+ (lib.convert/->mbql5 query))]
(is (=? [{:base-type :type/BigInteger
:semantic-type :type/PK
:table-id (mt/id :products)
@@ -104,7 +104,7 @@
:type :query
:query {:source-card (u/the-id card)}}
mlv2-query (lib/query (mt/metadata-provider)
- (lib.convert/->pMBQL query))
+ (lib.convert/->mbql5 query))
breakouts (lib/breakoutable-columns mlv2-query)
agg-query (-> mlv2-query
(lib/breakout (second breakouts))
diff --git a/test/metabase/lib_metric/ast/build_test.cljc b/test/metabase/lib_metric/ast/build_test.cljc
index 2867723d505..418e70e1f23 100644
--- a/test/metabase/lib_metric/ast/build_test.cljc
+++ b/test/metabase/lib_metric/ast/build_test.cljc
@@ -314,7 +314,7 @@
(deftest ^:parallel mbql-filter->ast-filter-exclude-day-of-week-test
(let [;; Exclude Monday (1) and Sunday (7) using ISO day-of-week
- ;; This is the pMBQL shape produced by lib/fe_util/exclude-date-filter-clause
+ ;; This is the MBQL 5 shape produced by lib/fe_util/exclude-date-filter-clause
result (ast.build/mbql-filter->ast-filter
[:!= {} [:get-day-of-week {} [:dimension {} uuid-2] :iso] 1 7])]
(is (some? result) "should produce an AST filter node")
diff --git a/test/metabase/measures/api_test.clj b/test/metabase/measures/api_test.clj
index 48c9afa45b6..b1c797c2204 100644
--- a/test/metabase/measures/api_test.clj
+++ b/test/metabase/measures/api_test.clj
@@ -23,7 +23,7 @@
;; ## Helper Fns
-(defn- pmbql-measure-definition
+(defn- mbql5-measure-definition
"Create an MBQL5 measure definition with a sum aggregation."
[table-id field-id]
(let [metadata-provider (lib-be/application-database-metadata-provider (t2/select-one-fn :db_id :model/Table :id table-id))
@@ -89,7 +89,7 @@
{:name "A Measure"
:description "I did it!"
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))})))))
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))})))))
;; ## PUT /api/measure
@@ -97,7 +97,7 @@
(testing "PUT /api/measure/:id"
(testing "test security. requires superuser perms"
(mt/with-temp [:model/Measure measure {:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(is (= "You don't have permissions to do that."
(mt/user-http-request :rasta :put 403 (str "measure/" (:id measure))
{:name "abc"
@@ -124,7 +124,7 @@
(deftest update-test
(testing "PUT /api/measure/:id"
(mt/with-temp [:model/Measure {:keys [id]} {:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(is (=? {:name "Updated Measure"
:description nil
:creator_id (mt/user->id :rasta)
@@ -141,13 +141,13 @@
:description nil
:table_id (mt/id :venues)
:revision_message "I got me some revisions"
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}))))))
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}))))))
(deftest partial-update-test
(testing "PUT /api/measure/:id"
(testing "Can I update a measure's name without specifying all fields?"
(mt/with-temp [:model/Measure measure {:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
;; just make sure API call doesn't barf
(is (some? (mt/user-http-request :crowberto :put 200 (str "measure/" (u/the-id measure))
{:name "Cool name"
@@ -157,7 +157,7 @@
(testing "PUT /api/measure/:id"
(testing "Can we archive a Measure with the PUT endpoint?"
(mt/with-temp [:model/Measure {:keys [id]} {:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(is (map? (mt/user-http-request :crowberto :put 200 (str "measure/" id)
{:archived true, :revision_message "Archive the Measure"})))
(is (true?
@@ -168,7 +168,7 @@
(testing "Can we unarchive a Measure with the PUT endpoint?"
(mt/with-temp [:model/Measure {:keys [id]} {:archived true
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(is (map? (mt/user-http-request :crowberto :put 200 (str "measure/" id)
{:archived false, :revision_message "Unarchive the Measure"})))
(is (= false
@@ -180,7 +180,7 @@
(testing "GET /api/measure/:id"
(testing "test security. Requires manage-table-metadata perms for the Table it references"
(mt/with-temp [:model/Measure measure {:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(mt/with-no-data-perms-for-all-users!
(is (= "You don't have permissions to do that."
(mt/user-http-request :rasta :get 403 (str "measure/" (u/the-id measure))))))))))
@@ -189,7 +189,7 @@
(testing "GET /api/measure/:id"
(mt/with-temp [:model/Measure {:keys [id]} {:creator_id (mt/user->id :crowberto)
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(mt/with-full-data-perms-for-all-users!
(is (=? {:name "Mock Measure"
:description nil
@@ -206,7 +206,7 @@
(testing "GET /api/measure/:id saves dimensions and dimension_mappings to the database"
(mt/with-temp [:model/Measure {:keys [id]} {:creator_id (mt/user->id :crowberto)
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(testing "no dimensions saved initially"
(let [initial-measure (t2/select-one :model/Measure :id id)]
(is (nil? (:dimensions initial-measure)))
@@ -226,7 +226,7 @@
(testing "GET /api/measure/:id returns dimensions with has-field-values populated"
(mt/with-temp [:model/Measure {:keys [id]} {:creator_id (mt/user->id :crowberto)
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(mt/with-full-data-perms-for-all-users!
(let [response (mt/user-http-request :rasta :get 200 (format "measure/%d" id))
dimensions (:dimensions response)]
@@ -243,14 +243,14 @@
(testing "GET /api/measure/"
(mt/with-temp [:model/Measure {id-1 :id} {:name "Measure 1"
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}
:model/Measure {id-2 :id} {:name "Measure 2"
:table_id (mt/id :products)
- :definition (pmbql-measure-definition (mt/id :products) (mt/id :products :price))}
+ :definition (mbql5-measure-definition (mt/id :products) (mt/id :products :price))}
;; archived measures shouldn't show up
:model/Measure {id-3 :id} {:archived true
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(mt/with-full-data-perms-for-all-users!
(is (=? [{:id id-1
:name "Measure 1"
@@ -305,7 +305,7 @@
(deftest api-accepts-mbql4-on-put-test
(testing "PUT /api/measure/:id accepts MBQL4 definitions and returns MBQL5"
(mt/with-temp [:model/Measure {measure-id :id} {:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(testing "MBQL4 fragment format"
(let [response (mt/user-http-request
:crowberto :put 200 (str "measure/" measure-id)
@@ -354,7 +354,7 @@
(testing "GET /api/measure/:id/dimension/:dimension-key/values"
(mt/with-temp [:model/Measure {:keys [id]} {:creator_id (mt/user->id :crowberto)
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure id)
price-dim (find-dimension-by-name hydrated "PRICE")]
@@ -371,7 +371,7 @@
(testing "GET /api/measure/:id/dimension/:dimension-key/search"
(mt/with-temp [:model/Measure {:keys [id]} {:creator_id (mt/user->id :crowberto)
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure id)
name-dim (find-dimension-by-name hydrated "NAME")]
@@ -386,7 +386,7 @@
(testing "GET /api/measure/:id/dimension/:dimension-key/remapping"
(mt/with-temp [:model/Measure {:keys [id]} {:creator_id (mt/user->id :crowberto)
:table_id (mt/id :venues)
- :definition (pmbql-measure-definition (mt/id :venues) (mt/id :venues :price))}]
+ :definition (mbql5-measure-definition (mt/id :venues) (mt/id :venues :price))}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure id)
price-dim (find-dimension-by-name hydrated "PRICE")]
diff --git a/test/metabase/metabot/tools/sql/tools_test.clj b/test/metabase/metabot/tools/sql/tools_test.clj
index 6714040de57..b25eb39e199 100644
--- a/test/metabase/metabot/tools/sql/tools_test.clj
+++ b/test/metabase/metabot/tools/sql/tools_test.clj
@@ -31,10 +31,10 @@
(is (= query-id (:query-id result)))
(is (= "SELECT * FROM users WHERE id = 2" (:query-content result)))))
- (testing "edit with JSON-parsed pMBQL query (string enum values)"
+ (testing "edit with JSON-parsed MBQL 5 query (string enum values)"
(let [original-sql "SELECT * FROM users WHERE id = 1"
- query-id "q-pmbql"
- ;; Simulates JSON round-tripped pMBQL: keyword keys, string values
+ query-id "q-mbql5"
+ ;; Simulates JSON round-tripped MBQL 5: keyword keys, string values
queries-state {query-id {:lib/type "mbql/query"
:database db-id
:stages [{:lib/type "mbql.stage/native"
@@ -101,10 +101,10 @@
(is (= new-sql (:query-content result)))
(is (= db-id (:database result)))))
- (testing "replace with JSON-parsed pMBQL query (string enum values)"
+ (testing "replace with JSON-parsed MBQL 5 query (string enum values)"
(let [original-sql "SELECT * FROM users"
new-sql "SELECT id, name FROM customers"
- query-id "q-pmbql-replace"
+ query-id "q-mbql5-replace"
queries-state {query-id {:lib/type "mbql/query"
:database db-id
:stages [{:lib/type "mbql.stage/native"
@@ -133,23 +133,23 @@
(is (= "SELECT 2" (:query-content result)))
(is (= db-id (:database result))))))))))
-(deftest update-query-sql-with-json-pmbql-test
+(deftest update-query-sql-with-json-mbql5-test
(mt/test-drivers #{:h2}
(mt/with-temp [:model/Database {db-id :id} {:engine :h2}]
- (testing "pMBQL query with string enum values (as received from frontend JSON)"
+ (testing "MBQL 5 query with string enum values (as received from frontend JSON)"
;; Simulates what cheshire/decode+kw produces: keyword keys but string values
;; for enum-like fields such as :lib/type.
- (let [json-pmbql {:lib/type "mbql/query"
+ (let [json-mbql5 {:lib/type "mbql/query"
:database db-id
:stages [{:lib/type "mbql.stage/native"
:native "SELECT 1"}]}
- result (sql-common/update-query-sql json-pmbql "SELECT 2")]
+ result (sql-common/update-query-sql json-mbql5 "SELECT 2")]
(is (lib/native-only-query? result))
(is (= "SELECT 2" (lib/raw-native-query result)))))
- (testing "already-normalized pMBQL query"
+ (testing "already-normalized MBQL 5 query"
(let [mp (mt/metadata-provider)
- pmbql (lib/native-query mp "SELECT 1")
- result (sql-common/update-query-sql pmbql "SELECT 2")]
+ mbql5 (lib/native-query mp "SELECT 1")
+ result (sql-common/update-query-sql mbql5 "SELECT 2")]
(is (lib/native-only-query? result))
(is (= "SELECT 2" (lib/raw-native-query result)))))
(testing "legacy MBQL query"
diff --git a/test/metabase/metrics/api_dataset_test.clj b/test/metabase/metrics/api_dataset_test.clj
index 043968c6b99..6b46c5801ec 100644
--- a/test/metabase/metrics/api_dataset_test.clj
+++ b/test/metabase/metrics/api_dataset_test.clj
@@ -650,11 +650,11 @@
(testing "POST /api/metric/dataset with source-measure count"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Venue Count"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [response (dataset-request {:expression [:measure {:lib/uuid "a"} (:id measure)]})]
(is (= "completed" (:status response)))
@@ -665,11 +665,11 @@
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
price-col (lib.metadata/field mp (mt/id :venues :price))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/sum price-col)))]
(mt/with-temp [:model/Measure measure {:name "Total Price"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [response (dataset-request {:expression [:measure {:lib/uuid "a"} (:id measure)]})]
(is (= "completed" (:status response)))
@@ -680,11 +680,11 @@
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :products))
rating-col (lib.metadata/field mp (mt/id :products :rating))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/avg (lib/case [[(lib/>= rating-col 4) 1]] 0))))]
(mt/with-temp [:model/Measure measure {:name "High Rating Ratio"
:table_id (mt/id :products)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [response (dataset-request {:expression [:measure {:lib/uuid "a"} (:id measure)]})]
(is (= "completed" (:status response)))
@@ -710,11 +710,11 @@
(testing "POST /api/metric/dataset with source-measure and filter"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Venue Count"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure (:id measure))
price-dim (find-measure-dimension-by-name hydrated "PRICE")]
@@ -728,11 +728,11 @@
(testing "POST /api/metric/dataset with source-measure and projection"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Venue Count"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure (:id measure))
price-dim (find-measure-dimension-by-name hydrated "PRICE")]
@@ -746,11 +746,11 @@
(testing "POST /api/metric/dataset with source-measure and temporal bucket"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :checkins))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Checkin Count"
:table_id (mt/id :checkins)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure (:id measure))
date-dim (find-measure-dimension-by-name hydrated "DATE")]
@@ -764,11 +764,11 @@
(testing "POST /api/metric/dataset with source-measure and binning"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Venue Count"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure (:id measure))
lat-dim (find-measure-dimension-by-name hydrated "LATITUDE")]
@@ -782,11 +782,11 @@
(testing "POST /api/metric/dataset with source-measure combining filter and projection"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Venue Count"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [hydrated (hydrate-measure (:id measure))
price-dim (find-measure-dimension-by-name hydrated "PRICE")
@@ -836,11 +836,11 @@
(testing "POST /api/metric/dataset respects measure data permissions"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Protected Measure"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-no-data-perms-for-all-users!
(is (= "You don't have permissions to do that."
(dataset-request-error 403 {:expression [:measure {:lib/uuid "a"} (:id measure)]}))))))))
@@ -859,11 +859,11 @@
(testing "POST /api/metric/dataset allows measure execution when user has data perms"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Accessible Measure"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
(mt/with-full-data-perms-for-all-users!
(let [response (dataset-request {:expression [:measure {:lib/uuid "a"} (:id measure)]})]
(is (= "completed" (:status response)))
@@ -887,11 +887,11 @@
(testing "POST /api/metric/dataset allows admin to execute measures regardless of data perms"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-query (-> (lib/query mp table-metadata)
+ mbql5-query (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Protected Measure"
:table_id (mt/id :venues)
- :definition pmbql-query}]
+ :definition mbql5-query}]
;; crowberto is admin and can bypass data perms
(let [response (mt/user-http-request :crowberto :post 202 "metric/dataset"
{:definition {:expression [:measure {:lib/uuid "a"} (:id measure)]}})]
@@ -1018,7 +1018,7 @@
;;; +----------------------------------------------------------------------------------------------------------------+
(defn- create-orders-products-join-query
- "Create a pMBQL query joining Orders with Products on product_id."
+ "Create a MBQL 5 query joining Orders with Products on product_id."
[]
(let [mp (mt/metadata-provider)
orders-table (lib.metadata/table mp (mt/id :orders))
@@ -1134,7 +1134,7 @@
"should have 49 months of order data")))))))
(defn- create-orders-products-join-sum-price-query
- "Create a pMBQL query joining Orders with Products, aggregating SUM(Products.PRICE).
+ "Create a MBQL 5 query joining Orders with Products, aggregating SUM(Products.PRICE).
This exercises the case where the aggregation references a column from the joined table,
which requires the join's fields to be visible across the two-stage query boundary."
([]
diff --git a/test/metabase/metrics/api_test.clj b/test/metabase/metrics/api_test.clj
index cad35ccfd1f..4b8b3b6bd4a 100644
--- a/test/metabase/metrics/api_test.clj
+++ b/test/metabase/metrics/api_test.clj
@@ -243,11 +243,11 @@
(testing "POST /api/metric/dataset with measure expression"
(let [mp (mt/metadata-provider)
table-metadata (lib.metadata/table mp (mt/id :venues))
- pmbql-definition (-> (lib/query mp table-metadata)
+ mbql5-definition (-> (lib/query mp table-metadata)
(lib/aggregate (lib/count)))]
(mt/with-temp [:model/Measure measure {:name "Test Measure"
:table_id (mt/id :venues)
- :definition pmbql-definition}]
+ :definition mbql5-definition}]
(mt/with-full-data-perms-for-all-users!
(let [response (mt/user-http-request :rasta :post 202 "metric/dataset"
{:definition {:expression [:measure {:lib/uuid "a"} (:id measure)]}})]
diff --git a/test/metabase/queries/models/card_test.clj b/test/metabase/queries/models/card_test.clj
index e24c7b766a4..35737dc5154 100644
--- a/test/metabase/queries/models/card_test.clj
+++ b/test/metabase/queries/models/card_test.clj
@@ -376,7 +376,7 @@
(defn- native-query-card
"Build a card map with a native query containing the given template tags.
- Uses lib to construct a properly normalized pMBQL query."
+ Uses lib to construct a properly normalized MBQL 5 query."
[sql template-tags]
{:dataset_query (lib/with-template-tags
(lib/native-query meta/metadata-provider sql)
diff --git a/test/metabase/queries_rest/api/card_test.clj b/test/metabase/queries_rest/api/card_test.clj
index 77400870872..542e6012e66 100644
--- a/test/metabase/queries_rest/api/card_test.clj
+++ b/test/metabase/queries_rest/api/card_test.clj
@@ -104,9 +104,9 @@
:query {:source-table (u/the-id table-or-id)
:aggregation [[:count]]}}))
-(defn pmbql-count-query
+(defn mbql5-count-query
([]
- (pmbql-count-query (mt/id) (mt/id :venues)))
+ (mbql5-count-query (mt/id) (mt/id :venues)))
([db-or-id table-or-id]
(let [metadata-provider (lib-be/application-database-metadata-provider (u/the-id db-or-id))
@@ -732,7 +732,7 @@
(perms/grant-collection-readwrite-permissions! (perms-group/all-users) collection)
(mt/with-model-cleanup [:model/Card]
(doseq [[mbql-version query] {"MBQL" (mbql-count-query)
- "pMBQL" (pmbql-count-query)}]
+ "MBQL 5" (mbql5-count-query)}]
(testing mbql-version
(let [card (assoc (card-with-name-and-query (mt/random-name) query)
:collection_id (u/the-id collection)
@@ -846,7 +846,7 @@
(deftest create-and-update-metric-card-validation-test
(testing "POST /api/card"
- (let [query (pmbql-count-query)
+ (let [query (mbql5-count-query)
card-name (mt/random-name)
card (-> (card-with-name-and-query card-name query)
(assoc :type :metric))
@@ -3738,7 +3738,7 @@
venues (lib.metadata/table metadata-provider (mt/id :venues))
query (lib/query metadata-provider venues)
response (mt/user-http-request :crowberto :post 200 "card"
- {:name "pMBQL Card"
+ {:name "MBQL 5 Card"
:dataset_query (dissoc query :lib/metadata)
:display :table
:visualization_settings {}})]
diff --git a/test/metabase/query_permissions/impl_test.clj b/test/metabase/query_permissions/impl_test.clj
index 5723a1d18b4..1813e80a568 100644
--- a/test/metabase/query_permissions/impl_test.clj
+++ b/test/metabase/query_permissions/impl_test.clj
@@ -244,8 +244,8 @@
(qp.preprocess/preprocess
query)))))))))
-(deftest ^:parallel pmbql-query-test
- (testing "Should be able to calculate permissions for a pMBQL query (#39024)"
+(deftest ^:parallel mbql5-query-test
+ (testing "Should be able to calculate permissions for a MBQL 5 query (#39024)"
(let [metadata-provider (mt/metadata-provider)
venues (lib.metadata/table metadata-provider (mt/id :venues))
query (lib/query metadata-provider venues)]
@@ -253,8 +253,8 @@
:perms/create-queries {(mt/id :venues) :query-builder}}
(query-perms/required-perms-for-query query))))))
-(deftest ^:parallel pmbql-native-query-test
- (testing "Should be able to calculate permissions for a pMBQL native query (#39024)"
+(deftest ^:parallel mbql5-native-query-test
+ (testing "Should be able to calculate permissions for a MBQL 5 native query (#39024)"
(let [metadata-provider (mt/metadata-provider)
query (lib/query metadata-provider {:lib/type :mbql.stage/native
:native "SELECT *;"})]
@@ -293,14 +293,14 @@
:paths #{(format "/collection/%d/read/" collection-1-id)
(format "/collection/%d/read/" collection-2-id)}}
(query-perms/required-perms-for-query native-query)))
- (testing "pMBQL query"
+ (testing "MBQL 5 query"
(is (= {:perms/create-queries :query-builder-and-native
:perms/view-data :unrestricted
:paths #{(format "/collection/%d/read/" collection-1-id)
(format "/collection/%d/read/" collection-2-id)}}
(query-perms/required-perms-for-query
(lib/query (mt/metadata-provider)
- (lib/->pMBQL native-query)))))))))))
+ (lib/->mbql5 native-query)))))))))))
(deftest ^:parallel native-query-source-card-id-join-permissions-test
(testing "MBQL query with native source card (#30077)"
diff --git a/test/metabase/query_processor/date_bucketing_test.clj b/test/metabase/query_processor/date_bucketing_test.clj
index e28c9b502ca..762c404fe98 100644
--- a/test/metabase/query_processor/date_bucketing_test.clj
+++ b/test/metabase/query_processor/date_bucketing_test.clj
@@ -1767,7 +1767,7 @@
(is (= 7 (count (mt/rows processed))))
(is (= 7 (count (mt/rows mbql-processed))))
(is (= (get-in (qp/process-query mbql-query) [:data :native_form])
- (get-in (qp/process-query (lib.convert/->pMBQL mbql-query)) [:data :native_form])
+ (get-in (qp/process-query (lib.convert/->mbql5 mbql-query)) [:data :native_form])
(get-in (qp/process-query query) [:data :native_form]))))))))
(deftest ^:parallel filter-by-expression-relative-time-interval-test
@@ -1791,7 +1791,7 @@
(is (= 7 (count (mt/rows processed))))
(is (= 7 (count (mt/rows mbql-processed))))
(is (= (get-in (qp/process-query mbql-query) [:data :native_form])
- (get-in (qp/process-query (lib.convert/->pMBQL mbql-query)) [:data :native_form])
+ (get-in (qp/process-query (lib.convert/->mbql5 mbql-query)) [:data :native_form])
(get-in (qp/process-query query) [:data :native_form]))))))))
;; TODO -- is this really date BUCKETING? Does this BELONG HERE?!
diff --git a/test/metabase/query_processor/middleware/expand_macros_test.clj b/test/metabase/query_processor/middleware/expand_macros_test.clj
index b6e4808e67f..8baf45a9bd3 100644
--- a/test/metabase/query_processor/middleware/expand_macros_test.clj
+++ b/test/metabase/query_processor/middleware/expand_macros_test.clj
@@ -13,7 +13,7 @@
^{:clj-kondo/ignore [:deprecated-namespace]} [metabase.query-processor.store :as qp.store]))
(defn- expand-macros
- "If input is a legacy query, convert to pMBQL, call [[expand-macros/expand-macros]], then convert back to legacy. This
+ "If input is a legacy query, convert to MBQL 5, call [[expand-macros/expand-macros]], then convert back to legacy. This
way we don't need to update all the tests below right away."
[query]
(if (:type query) ; legacy query
diff --git a/test/metabase/query_processor/middleware/fetch_source_query_test.clj b/test/metabase/query_processor/middleware/fetch_source_query_test.clj
index 0a504731e85..0a3c84d8dba 100644
--- a/test/metabase/query_processor/middleware/fetch_source_query_test.clj
+++ b/test/metabase/query_processor/middleware/fetch_source_query_test.clj
@@ -19,7 +19,7 @@
[metabase.test :as mt]))
(defn resolve-source-cards* [query]
- ;; Handle old tests written with legacy queries. Convert legacy query to pMBQL and then convert results
+ ;; Handle old tests written with legacy queries. Convert legacy query to MBQL 5 and then convert results
;; back. That way we don't need to update all the tests immediately and can do so at our leisure.
(letfn [(thunk [] (let [mlv2-query (lib.query/query (qp.store/metadata-provider) query)
resolved (fetch-source-query/resolve-source-cards mlv2-query)]
diff --git a/test/metabase/query_processor/middleware/fix_bad_field_id_refs_test.clj b/test/metabase/query_processor/middleware/fix_bad_field_id_refs_test.clj
index e8e4d2b4a60..5d527ed00a2 100644
--- a/test/metabase/query_processor/middleware/fix_bad_field_id_refs_test.clj
+++ b/test/metabase/query_processor/middleware/fix_bad_field_id_refs_test.clj
@@ -292,8 +292,8 @@
:breakout [[:expression "My Date" {:base-type "type/DateTime"}]
[:field 101 {:base-type "type/Text"}]]
:aggregation [[:cum-count]]}}
- pmbql (lib/query mp legacy-query)
- pmbql-with-meta (assoc-in pmbql [:stages 0 :lib/stage-metadata]
+ mbql5 (lib/query mp legacy-query)
+ mbql5-with-meta (assoc-in mbql5 [:stages 0 :lib/stage-metadata]
{:lib/type :metadata/results
:columns [{:lib/type :metadata/column
:name "DATE_COL"
@@ -305,7 +305,7 @@
:base-type :type/Text
:id 101
:table-id 10}]})
- result (fix-bad-field-id-refs/fix-bad-field-id-refs pmbql-with-meta)]
+ result (fix-bad-field-id-refs/fix-bad-field-id-refs mbql5-with-meta)]
(testing "expression definition must retain :lib/expression-name after fix-bad-field-id-refs"
(is (=? {:stages [{} {:expressions [[:field {:lib/expression-name "My Date"} "DATE_COL"]]}]}
result)))
diff --git a/test/metabase/query_processor/middleware/metrics_test.clj b/test/metabase/query_processor/middleware/metrics_test.clj
index 6520e7e5f0a..36a8dcfb1c3 100644
--- a/test/metabase/query_processor/middleware/metrics_test.clj
+++ b/test/metabase/query_processor/middleware/metrics_test.clj
@@ -685,7 +685,7 @@
[:field (meta/id :venues :price) {}]]]]]
{:display-name "My Cool Aggregation"}]]}
expand-macros (fn [mbql-query]
- (lib.convert/->legacy-MBQL (adjust (lib/query mp (lib.convert/->pMBQL mbql-query)))))]
+ (lib.convert/->legacy-MBQL (adjust (lib/query mp (lib.convert/->mbql5 mbql-query)))))]
(comment
(testing "nested 1 level"
(is (=? (lib.tu.macros/mbql-query nil
diff --git a/test/metabase/query_processor/middleware/optimize_temporal_filters_test.clj b/test/metabase/query_processor/middleware/optimize_temporal_filters_test.clj
index 23f37507f78..ed01854bc41 100644
--- a/test/metabase/query_processor/middleware/optimize_temporal_filters_test.clj
+++ b/test/metabase/query_processor/middleware/optimize_temporal_filters_test.clj
@@ -21,7 +21,7 @@
(defn- optimize-filter [clause]
(let [query (lib/query meta/metadata-provider (meta/table-metadata :orders))]
(or (-> clause
- lib/->pMBQL
+ lib/->mbql5
(->> (#'optimize-temporal-filters/optimize-filter query [:stages 0]))
lib/->legacy-MBQL)
clause)))
diff --git a/test/metabase/query_processor/pipeline_queries_test.clj b/test/metabase/query_processor/pipeline_queries_test.clj
index dd254c2bfa6..69c3b857d0f 100644
--- a/test/metabase/query_processor/pipeline_queries_test.clj
+++ b/test/metabase/query_processor/pipeline_queries_test.clj
@@ -20,7 +20,7 @@
(declare ^:private $price)
-(defmacro ^:private pmbql-query
+(defmacro ^:private mbql5-query
{:style/indent 1}
[table-name & body]
`(let [query# (query-for-table-id ~(keyword table-name))
@@ -28,22 +28,22 @@
(-> query#
~@body)))
-(defmacro ^:private run-pmbql-query
+(defmacro ^:private run-mbql5-query
{:style/indent 1}
[table-name & body]
- `(qp/process-query (pmbql-query ~table-name ~@body)))
+ `(qp/process-query (mbql5-query ~table-name ~@body)))
(deftest ^:parallel pipeline-queries-test
- (testing "Ensure that the QP can handle pMBQL queries"
+ (testing "Ensure that the QP can handle MBQL 5 queries"
(is (= [6]
(mt/first-row
- (run-pmbql-query :venues
+ (run-mbql5-query :venues
(lib/aggregate (lib/count))
(lib/filter (lib/= $price 4))))))))
(deftest ^:parallel denormalized-pipeline-queries-test
- (testing "Ensure that the QP can handle pMBQL queries as they'd come in from the REST API or application database"
- (let [query (-> (pmbql-query :venues
+ (testing "Ensure that the QP can handle MBQL 5 queries as they'd come in from the REST API or application database"
+ (let [query (-> (mbql5-query :venues
(lib/aggregate (lib/count))
(lib/filter (lib/= $price 4)))
(dissoc :lib/metadata)
diff --git a/test/metabase/segments/api_test.clj b/test/metabase/segments/api_test.clj
index e36fb7c8bc3..2232af82cf5 100644
--- a/test/metabase/segments/api_test.clj
+++ b/test/metabase/segments/api_test.clj
@@ -34,7 +34,7 @@
{:source-table table-id
:filter [:= [:field field-id nil] value]})
-(defn- pmbql-segment-definition
+(defn- mbql5-segment-definition
"Create an MBQL5 segment definition"
[table-id field-id value]
(let [metadata-provider (lib-be/application-database-metadata-provider (t2/select-one-fn :db_id :model/Table :id table-id))
@@ -87,7 +87,7 @@
(deftest create-segment-test
(doseq [[format-name definition-fn] {"MBQL4" (partial mbql4-segment-definition (mt/id :users))
- "pMBQL" (partial pmbql-segment-definition (mt/id :users))}]
+ "MBQL5" (partial mbql5-segment-definition (mt/id :users))}]
(testing format-name
(is (= {:name "A Segment"
:description "I did it!"
@@ -145,7 +145,7 @@
(mt/with-temp [:model/Segment {:keys [id]} {:table_id (mt/id :users)
:definition (mbql4-segment-definition (mt/id :users) (mt/id :users :name) "cans")}]
(doseq [[format-name eq-fn] [["MBQL4" (partial mbql4-segment-definition (mt/id :users))]
- ["pMBQL" (partial pmbql-segment-definition (mt/id :users))]]]
+ ["MBQL5" (partial mbql5-segment-definition (mt/id :users))]]]
(testing format-name
(is (= {:name "Costa Rica"
:description nil
@@ -276,7 +276,7 @@
(deftest fetch-segment-test
(testing "GET /api/segment/:id"
(doseq [[format-name definition-fn] {"MBQL4" (partial mbql4-segment-definition (mt/id :users))
- "pMBQL" (partial pmbql-segment-definition (mt/id :users))}]
+ "MBQL5" (partial mbql5-segment-definition (mt/id :users))}]
(testing format-name
(mt/with-temp [:model/Segment {:keys [id]} {:creator_id (mt/user->id :crowberto)
:table_id (mt/id :users)
diff --git a/test/metabase/xrays/automagic_dashboards/comparison_test.clj b/test/metabase/xrays/automagic_dashboards/comparison_test.clj
index 72d4c69242d..7b7cf1e2f97 100644
--- a/test/metabase/xrays/automagic_dashboards/comparison_test.clj
+++ b/test/metabase/xrays/automagic_dashboards/comparison_test.clj
@@ -10,7 +10,7 @@
[metabase.xrays.test-util.automagic-dashboards :refer [with-rollback-only-transaction]]
[toucan2.core :as t2]))
-(defn- pmbql-segment-definition
+(defn- mbql5-segment-definition
"Create an MBQL5 segment definition"
[table-id field-id value]
(let [metadata-provider (mt/metadata-provider)
@@ -22,7 +22,7 @@
(def ^:private segment
(delay
{:table_id (mt/id :venues)
- :definition (pmbql-segment-definition (mt/id :venues) (mt/id :venues :price) 10)}))
+ :definition (mbql5-segment-definition (mt/id :venues) (mt/id :venues :price) 10)}))
(defn- test-comparison
[left right]
diff --git a/test/metabase/xrays/automagic_dashboards/core_test.clj b/test/metabase/xrays/automagic_dashboards/core_test.clj
index 982bc10b513..52d6881a6bb 100644
--- a/test/metabase/xrays/automagic_dashboards/core_test.clj
+++ b/test/metabase/xrays/automagic_dashboards/core_test.clj
@@ -177,7 +177,7 @@
(is (= entity query))
(is (= source (t2/select-one :model/Table (mt/id :orders)))))))))
-(defn- pmbql-segment-definition
+(defn- mbql5-segment-definition
"Create an MBQL5 segment definition"
[table-id field-id value]
(let [metadata-provider (lib-be/application-database-metadata-provider (t2/select-one-fn :db_id :model/Table :id table-id))
@@ -190,7 +190,7 @@
(testing "Demonstrate the stated methods in which ->root computes the source of a :model/Segment"
(testing "The source of a segment is its underlying table."
(mt/with-temp [:model/Segment segment {:table_id (mt/id :venues)
- :definition (pmbql-segment-definition (mt/id :venues) (mt/id :venues :price) 10)}]
+ :definition (mbql5-segment-definition (mt/id :venues) (mt/id :venues :price) 10)}]
(let [{:keys [entity source]} (#'magic/->root segment)]
(is (= entity segment))
(is (= source (t2/select-one :model/Table (mt/id :venues)))))))))
@@ -854,7 +854,7 @@
(mt/with-temp [:model/Segment {table-id :table_id
segment-name :name
:as segment} {:table_id (mt/id :venues)
- :definition (pmbql-segment-definition (mt/id :venues) (mt/id :venues :price) 10)}]
+ :definition (mbql5-segment-definition (mt/id :venues) (mt/id :venues :price) 10)}]
(is (= (format "A look at %s in the %s segment"
(u/capitalize-en (t2/select-one-fn :name :model/Table :id table-id))
segment-name)
diff --git a/test/metabase/xrays/related_test.clj b/test/metabase/xrays/related_test.clj
index 085a7b1e7c2..40638737054 100644
--- a/test/metabase/xrays/related_test.clj
+++ b/test/metabase/xrays/related_test.clj
@@ -20,7 +20,7 @@
["segment" 1]]
[:metric 1]]))))
-(defn- pmbql-segment-definition
+(defn- mbql5-segment-definition
"Create an MBQL5 segment definition"
[table-id field-id value]
(let [metadata-provider (lib-be/application-database-metadata-provider (t2/select-one-fn :db_id :model/Table :id table-id))
@@ -63,9 +63,9 @@
:dataset_query (mt/mbql-query venues {:aggregation [[:count]]
:breakout [$category_id]})}
:model/Segment {segment-id-a :id} {:table_id (mt/id :venues)
- :definition (pmbql-segment-definition (mt/id :venues) (mt/id :venues :category_id) nil)}
+ :definition (mbql5-segment-definition (mt/id :venues) (mt/id :venues :category_id) nil)}
:model/Segment {segment-id-b :id} {:table_id (mt/id :venues)
- :definition (pmbql-segment-definition (mt/id :venues) (mt/id :venues :name) nil)}
+ :definition (mbql5-segment-definition (mt/id :venues) (mt/id :venues :name) nil)}
:model/Card {card-id-a :id} {:table_id (mt/id :venues)
:dataset_query (mt/mbql-query venues
{:aggregation [[:sum $price]]