The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Replace 'MLv2' with 'Lib' or 'MBQL 5' in docstrings and function names (#72121)
Cam Saul629c10e7333c
diff --git a/deps.edn b/deps.ednindex d8cd42c0dc1..45cada0063b 100644--- a/deps.edn+++ b/deps.edn@@ -901,7 +901,7 @@:extra-paths ["dev/src"]:main-opts ["-m" "dev.migrate"]}- ;; run tests against MLv2. Very fast since this is almost all ^:parallel+ ;; run tests against Lib. Very fast since this is almost all ^:parallel:test/lib{:exec-args {:only ["test/metabase/lib""test/metabase/lib_be"]}}@@ -928,7 +928,7 @@{:exec-args {:only ["enterprise/backend/test/metabase_enterprise/transforms""enterprise/backend/test/metabase_enterprise/transforms_python"]}}-;; test all MBQL related stuff: MLv2, the legacy shared `metabase.legacy-mbql` code, and the QP+;; test all MBQL related stuff: Lib, the legacy shared `metabase.legacy-mbql` code, and the QP;;;; clj -X:dev:ee:ee-dev:test:test/mbql:test/mbqldiff --git a/dev/src/dev/fe_helpers.cljs b/dev/src/dev/fe_helpers.cljsindex a9004404ae9..f4ddfe18844 100644--- a/dev/src/dev/fe_helpers.cljs+++ b/dev/src/dev/fe_helpers.cljs@@ -23,8 +23,8 @@(.-dataset_query (current-card)))(defn current-query- "Gets the MLv2 query for the currently loaded question.+ "Gets the MBQL 5 query for the currently loaded question.- Hack: This relies on a dev-mode-only global property that's set whenever a Question object is converted to MLv2."+ Hack: This relies on a dev-mode-only global property that's set whenever a Question object is converted to Lib/MBQL 5."[]- (.-__MLv2_query js/window))+ (.-__lib_query js/window))diff --git a/docs/developers-guide/driver-changelog.md b/docs/developers-guide/driver-changelog.mdindex 95838324cf3..a8642d437cc 100644--- a/docs/developers-guide/driver-changelog.md+++ b/docs/developers-guide/driver-changelog.md@@ -4,6 +4,10 @@ title: Driver interface changelog# Driver Interface Changelog+## Metabase 0.61.0++- `driver/field-reference-mlv2`, deprecated in 0.57.0, has now been removed.+## Metabase 0.60.0- Added `validate-impersonated-query` multimethod. This is used for drivers to perform validation on impersonated native queries.diff --git a/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js b/e2e/test/scenarios/joins/joins-reproductions.cy.spec.jsindex 0ea474b0024..b21761b321b 100644--- a/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js+++ b/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js@@ -1089,7 +1089,7 @@ describe("issue 31769", () => {});});- it("shouldn't drop joins using MLv2 format (metabase#31769)", () => {+ it("shouldn't drop joins using Lib/MBQL 5 (metabase#31769)", () => {H.selectSavedQuestionsToJoin("Q1", "Q2");H.popover().findByText("Products → Category").click();diff --git a/frontend/src/metabase-lib/v1/Question.ts b/frontend/src/metabase-lib/v1/Question.tsindex 35535e64e7c..38f98f180ae 100644--- a/frontend/src/metabase-lib/v1/Question.ts+++ b/frontend/src/metabase-lib/v1/Question.ts@@ -98,9 +98,9 @@ class Question {*/_parameterValues: ParameterValuesMap;- private __mlv2Query: Lib.Query | undefined;+ private __libQuery: Lib.Query | undefined;- private __mlv2MetadataProvider: Lib.MetadataProvider | undefined;+ private __libMetadataProvider: Lib.MetadataProvider | undefined;/*** Question constructor@@ -807,30 +807,30 @@ class Question {query(): Query {if (InternalQuery.isDatasetQueryType(this.datasetQuery())) {- throw new Error("Internal query is not supported by MLv2");+ throw new Error("Internal query is not supported by Lib");}- this.__mlv2Query ??= Lib.fromJsQuery(+ this.__libQuery ??= Lib.fromJsQuery(this.metadataProvider(),this.datasetQuery(),);// Helpers for working with the current query from CLJS REPLs.if (process.env.NODE_ENV === "development") {- window.__MLv2_metadata = this.__mlv2MetadataProvider;- window.__MLv2_query = this.__mlv2Query;+ window.__lib_metadata = this.__libMetadataProvider;+ window.__lib_query = this.__libQuery;window.Lib = Lib;}- return this.__mlv2Query;+ return this.__libQuery;}private metadataProvider(): Lib.MetadataProvider {- this.__mlv2MetadataProvider ??= Lib.metadataProvider(+ this.__libMetadataProvider ??= Lib.metadataProvider(this.datasetQuery()?.database,this.metadata(),);- return this.__mlv2MetadataProvider;+ return this.__libMetadataProvider;}setQuery(query: Query): Question {diff --git a/frontend/src/metabase/common/components/AggregationPicker/AggregationPicker.tsx b/frontend/src/metabase/common/components/AggregationPicker/AggregationPicker.tsxindex 0f38ea26022..932dd672ab7 100644--- a/frontend/src/metabase/common/components/AggregationPicker/AggregationPicker.tsx+++ b/frontend/src/metabase/common/components/AggregationPicker/AggregationPicker.tsx@@ -122,7 +122,7 @@ export function AggregationPicker({useState<DefinedClauseName | null>(null);// For really simple inline expressions like Average([Price]),- // MLv2 can figure out that "Average" operator is used.+ // Lib can figure out that "Average" operator is used.// We don't want that though, so we don't break navigation inside the pickerconst [operator, setOperator] = useState<Lib.AggregationOperator | null>(isEditingExpression ? null : initialOperator,diff --git a/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.tsx b/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.tsxindex a1c469fcd5c..05cf5156000 100644--- a/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.tsx+++ b/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.tsx@@ -22,7 +22,7 @@ export type TableColumnInfoProps = {};/**- * @deprecated prefer to use the MLv2 query props+ * @deprecated prefer to use the Lib/MBQL 5 query props*/export function TableColumnInfo({className,diff --git a/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.unit.spec.js b/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.unit.spec.jsindex 076cae4b098..2cbb61d2345 100644--- a/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.unit.spec.js+++ b/frontend/src/metabase/common/components/MetadataInfo/ColumnInfo/ColumnInfo.unit.spec.js@@ -32,7 +32,7 @@ function setup(field) {});}-function setupMLv2(table, column) {+function setupLib(table, column) {const query = Lib.createTestQuery(SAMPLE_PROVIDER, DEFAULT_TEST_QUERY);const columns = Lib.visibleColumns(query, 0);const findColumn = columnFinder(query, columns);@@ -66,21 +66,21 @@ describe("FieldInfo", () => {});});-describe("FieldInfo (MLv2)", () => {+describe("FieldInfo (Lib)", () => {it("should show the given dimension's semantic type name", async () => {- setupMLv2("PRODUCTS", "CATEGORY");+ setupLib("PRODUCTS", "CATEGORY");expect(await screen.findByText("Category")).toBeInTheDocument();});it("should display the given dimension's description", async () => {- setupMLv2("PRODUCTS", "CATEGORY");+ setupLib("PRODUCTS", "CATEGORY");expect(await screen.findByText("The type of product.")).toBeInTheDocument();});it("should show a placeholder for a dimension with no description", () => {- setupMLv2("PRODUCTS", "CREATED_AT");+ setupLib("PRODUCTS", "CREATED_AT");expect(screen.getByText("No description")).toBeInTheDocument();});diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsxindex 8acab312b1d..043eb304e6e 100644--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsx+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsx@@ -182,7 +182,7 @@ DashCardMenu.shouldRender = ({}// Do not remove this check until we completely remove the old code related to Audit V1!- // MLv2 doesn't handle `internal` queries used for Audit V1.+ // Lib doesn't handle `internal` queries used for Audit V1.const isInternalQuery = InternalQuery.isDatasetQueryType(question.datasetQuery(),);diff --git a/frontend/src/metabase/dashboard/selectors.ts b/frontend/src/metabase/dashboard/selectors.tsindex 0e244791c58..19f276db333 100644--- a/frontend/src/metabase/dashboard/selectors.ts+++ b/frontend/src/metabase/dashboard/selectors.ts@@ -230,7 +230,7 @@ export const getDashcardHref = createSelector(!dashboard ||!dashcard ||!isQuestionDashCard(dashcard) ||- !dashcard.card.dataset_query // cards without queries will cause MLv2 to throw in getNewCardUrl+ !dashcard.card.dataset_query // cards without queries will cause Lib to throw in getNewCardUrl) {return undefined;}diff --git a/frontend/src/metabase/querying/common/utils/question.ts b/frontend/src/metabase/querying/common/utils/question.tsindex 7904a81667b..b21a6f5cfef 100644--- a/frontend/src/metabase/querying/common/utils/question.ts+++ b/frontend/src/metabase/querying/common/utils/question.ts@@ -51,7 +51,7 @@ export const isSavedQuestionChanged = (};export function cleanQuestion(question: Question): Question {- // Converting a query to MLv2 and back performs a clean-up+ // Converting a query to Lib/MBQL 5 and back performs a clean-upconst cleanQuestion = question.setQuery(Lib.dropEmptyStages(question.query()),);diff --git a/frontend/src/metabase/querying/drills/utils/column-extract-drill.tsx b/frontend/src/metabase/querying/drills/utils/column-extract-drill.tsxindex 9c34d49ff98..2823e5e172d 100644--- a/frontend/src/metabase/querying/drills/utils/column-extract-drill.tsx+++ b/frontend/src/metabase/querying/drills/utils/column-extract-drill.tsx@@ -72,7 +72,7 @@ export const columnExtractDrill: Drill<Lib.ColumnExtractDrillThruInfo> = ({export function getExample(info: Lib.ColumnExtractionInfo) {/*** @todo this should eventually be moved into Lib.displayInfo- * to avoid the keys going out of sync with the MLv2-defined extractions.+ * to avoid the keys going out of sync with the Lib-defined extractions.*/switch (info.tag) {case "hour-of-day":diff --git a/frontend/src/metabase/visualizations/components/legend/LegendCaption/LegendCaption.tsx b/frontend/src/metabase/visualizations/components/legend/LegendCaption/LegendCaption.tsxindex 97e93bd506e..e4a0883616c 100644--- a/frontend/src/metabase/visualizations/components/legend/LegendCaption/LegendCaption.tsx+++ b/frontend/src/metabase/visualizations/components/legend/LegendCaption/LegendCaption.tsx@@ -59,7 +59,7 @@ export const LegendCaption = ({}: LegendCaptionProps) => {/** Optimization: lazy computing the href on title focus & mouseenter only.- * Href computation uses getNewCardUrl, which makes a few MLv2 calls,+ * Href computation uses getNewCardUrl, which makes a few Lib calls,* which are expensive.* It's a performance issue on dashboards that have hundreds of dashcards* (during initial render and after changing dashboard parameters which candiff --git a/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj b/modules/drivers/sqlserver/src/metabase/driver/sqlserver.cljindex db80dcdbba5..7e5dc51e872 100644--- a/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj+++ b/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj@@ -802,8 +802,8 @@;; NULL` for us.(let [clause (into [op field];; we're compiling this ahead of time and throwing out the compiled value to make it easier to- ;; get the real database type of the expression... maybe when we convert this to MLv2 we can- ;; just use MLv2 metadata or type calculation functions instead.+ ;; get the real database type of the expression... maybe when we convert this to MBQL 5 we can+ ;; just use Lib metadata or type calculation functions instead.(or (when-let [field-database-type (h2x/database-type (sql.qp/->honeysql driver field))](when (#{"datetime" "datetime2" "datetimeoffset" "smalldatetime"} field-database-type)(map (fn [[_type val :as expr]]diff --git a/src/metabase/driver/util.clj b/src/metabase/driver/util.cljindex a7923f0c272..0e30be1323c 100644--- a/src/metabase/driver/util.clj+++ b/src/metabase/driver/util.clj@@ -224,8 +224,8 @@;;; this can get called in post-select which doesn't always have ID(mu/defn ensure-lib-database :- [:map[:lib/type [:= :metadata/database]]]- "Ensures the database is in MLv2 metadata format (SnakeHatingMap with kebab-case keys).- If passed a Toucan2 instance, converts it. If already MLv2 metadata, returns as-is."+ "Ensures the database is in Lib metadata format (SnakeHatingMap with kebab-case keys).+ If passed a Toucan2 instance, converts it. If already Lib metadata, returns as-is."[database :- [:or[:map[:lib/type [:= :metadata/database]]]diff --git a/src/metabase/driver_api/core.clj b/src/metabase/driver_api/core.cljindex b2ff61d353a..a8ddfc9b054 100644--- a/src/metabase/driver_api/core.clj+++ b/src/metabase/driver_api/core.clj@@ -73,7 +73,6 @@actions/violate-permission-constraintactions/violate-unique-constraintadd/add-alias-info- add/field-reference-mlv2annotate/aggregation-nameannotate/base-type-infererannotate/merged-column-infodiff --git a/src/metabase/legacy_mbql/schema.cljc b/src/metabase/legacy_mbql/schema.cljcindex 0e379960e08..e743ba55578 100644--- a/src/metabase/legacy_mbql/schema.cljc+++ b/src/metabase/legacy_mbql/schema.cljc@@ -648,7 +648,7 @@x [:ref ::ExpressionArg]);; Relax the arg types to ExpressionArg for concat since many DBs allow to concatenate non-string types. This also-;; aligns with the corresponding MLv2 schema and with the reference docs we publish.+;; aligns with the corresponding MBQL 5 schema and with the reference docs we publish.(defclause concata [:ref ::ExpressionArg]b [:ref ::ExpressionArg]diff --git a/src/metabase/lib/card.cljc b/src/metabase/lib/card.cljcindex 31cee932f05..08f1557a623 100644--- a/src/metabase/lib/card.cljc+++ b/src/metabase/lib/card.cljc@@ -63,7 +63,7 @@(lib.metadata.calculation/returned-columns (lib.query/query metadata-providerable card-query))))(mu/defn- ->card-metadata-column :- ::lib.schema.metadata/column- "Massage possibly-legacy Card results metadata into MLv2 ColumnMetadata. Note that `card` might be unavailable so we+ "Massage possibly-legacy Card results metadata into Lib ColumnMetadata. Note that `card` might be unavailable so weaccept both `card-id` and `card`.* `source-metadata-col` = (possibly snake_cased) column metadata from Card `:source-metadata`@@ -116,7 +116,7 @@(->> (lib.normalize/normalize ::lib.schema.metadata/column)))))(mu/defn ->card-metadata-columns :- [:maybe [:sequential ::lib.schema.metadata/column]]- "Massage possibly-legacy Card results metadata into MLv2 ColumnMetadata."+ "Massage possibly-legacy Card results metadata into Lib ColumnMetadata."([metadata-providerable cols](->card-metadata-columns metadata-providerable nil cols))diff --git a/src/metabase/lib/convert.cljc b/src/metabase/lib/convert.cljcindex a471432b0cd..0460c558d24 100644--- a/src/metabase/lib/convert.cljc+++ b/src/metabase/lib/convert.cljc@@ -766,7 +766,7 @@(seq inner-query) (assoc query-type inner-query)(seq parameters) (assoc :parameters parameters))))(catch #?(:clj Throwable :cljs :default) e- (throw (ex-info (lib.util/format "Error converting MLv2 query to legacy query: %s" (ex-message e))+ (throw (ex-info (lib.util/format "Error converting MBQL 5 query to legacy MBQL query: %s" (ex-message e)){:query query}e)))))diff --git a/src/metabase/lib/drill_thru/distribution.cljc b/src/metabase/lib/drill_thru/distribution.cljcindex f6fbdc57932..044852ed4e8 100644--- a/src/metabase/lib/drill_thru/distribution.cljc+++ b/src/metabase/lib/drill_thru/distribution.cljc@@ -39,7 +39,7 @@[metabase.lib.util :as lib.util][metabase.util.malli :as mu]))-;; TODO: The original `Question.distribution()` sets the display to `bar`, but that's out of scope for MLv2.+;; TODO: The original `Question.distribution()` sets the display to `bar`, but that's out of scope for Lib.;; Make sure the FE does this on the question after evolving the query.(mu/defn distribution-drill :- [:maybe ::lib.schema.drill-thru/drill-thru.distribution]"Select a column and see a histogram of how many rows fall into an automatic set of bins/buckets.diff --git a/src/metabase/lib/drill_thru/zoom.cljc b/src/metabase/lib/drill_thru/zoom.cljcindex 7229cea244a..74bb26dfd5c 100644--- a/src/metabase/lib/drill_thru/zoom.cljc+++ b/src/metabase/lib/drill_thru/zoom.cljc@@ -25,7 +25,7 @@- NoneA `:zoom` drill is a 'View details' drill when you click on the value of a PK column in a Table that has EXACTLY ONE- PK column. In MLv2, it is a no-op; in the frontend it changes the URL to take you to the 'object details' view for+ PK column. In Lib, it is a no-op; in the frontend it changes the URL to take you to the 'object details' view forthe row in question. For Tables with multiple PK columns, a [[metabase.lib.drill-thru.pk]] drill is returnedinstead.diff --git a/src/metabase/lib/equality.cljc b/src/metabase/lib/equality.cljcindex 941a2cf7088..ab20e68e947 100644--- a/src/metabase/lib/equality.cljc+++ b/src/metabase/lib/equality.cljc@@ -554,7 +554,7 @@ are known to be the same."to `needles` with the corresponding index into the `haystack`, or -1 if not found.DISCOURAGED: This is intended for use only by [[metabase.lib.js/find-column-indexes-from-legacy-refs]].- Other MLv2 code should use [[find-matching-column]] if the `haystack` is columns, or+ Other Lib code should use [[find-matching-column]] if the `haystack` is columns, or[[find-matching-ref]] if it's refs."[query :- ::lib.schema/querystage-number :- :intdiff --git a/src/metabase/lib/expression.cljc b/src/metabase/lib/expression.cljcindex 582b0b5d972..2443b03290a 100644--- a/src/metabase/lib/expression.cljc+++ b/src/metabase/lib/expression.cljc@@ -328,7 +328,7 @@expressionable (lib.common/->op-arg expressionable)];; TODO: This logic was removed as part of fixing #39059. We might want to bring it back for collisions with other;; expressions in the same stage; probably not with tables or earlier stages. De-duplicating names is supported by- ;; the QP code, and it should be powered by MLv2 in due course.+ ;; the QP code, and it should be powered by Lib in due course.#_(when (conflicting-name? query stage-number expression-name)(throw (ex-info "Expression name conflicts with a column in the same query stage"{:expression-name expression-name})))diff --git a/src/metabase/lib/field.cljc b/src/metabase/lib/field.cljcindex 74a24eaa9d8..2176aedbbb9 100644--- a/src/metabase/lib/field.cljc+++ b/src/metabase/lib/field.cljc@@ -758,7 +758,7 @@(mu/defn infer-has-field-values :- ::field-values-search-info.has-field-values"Determine the value of `:has-field-values` we should return for column metadata for frontend consumption to power- filter search widgets, either when returned by the the REST API or in MLv2 with [[field-values-search-info]].+ filter search widgets, either when returned by the the REST API or in Lib with [[field-values-search-info]].Note that this value is not necessarily the same as the value of `has_field_values` in the application database.`has_field_values` may be unset, in which case we will try to infer it. `:auto-list` is not currently understood bydiff --git a/src/metabase/lib/hierarchy.cljc b/src/metabase/lib/hierarchy.cljcindex a8e5ab977ce..30ada75f6fc 100644--- a/src/metabase/lib/hierarchy.cljc+++ b/src/metabase/lib/hierarchy.cljc@@ -1,7 +1,7 @@(ns metabase.lib.hierarchy(:refer-clojure :exclude [derive isa?]))-(defonce ^{:doc "Keyword hierarchy for MLv2 stuff."} hierarchy+(defonce ^{:doc "Keyword hierarchy for Lib stuff."} hierarchy(atom (make-hierarchy)))(defn derivediff --git a/src/metabase/lib/join.cljc b/src/metabase/lib/join.cljcindex 47d8573e3b0..fc0142fdfc1 100644--- a/src/metabase/lib/join.cljc+++ b/src/metabase/lib/join.cljc@@ -116,7 +116,7 @@If `old-alias` is `nil`, updates the RHS of all 'standard' conditions (binary filter clauses with the operator from[[join-condition-operators]], the LHS expression with columns from [[join-condition-lhs-columns]], the RHS expressionwith columns from [[join-condition-rhs-columns]]). This currently doesn't handle more complex filter clauses that- were created without the 'normal' MLv2 functions used by the frontend; we can add this in the future if we need it."+ were created without the 'normal' Lib functions used by the frontend; we can add this in the future if we need it."[join :- ::lib.join.util/partial-joinold-alias :- [:maybe ::lib.schema.join/alias]new-alias :- [:maybe ::lib.schema.join/alias]]@@ -722,7 +722,7 @@([query](available-join-strategies query -1))- ;; stage number is not currently used, but it is taken as a parameter for consistency with the rest of MLv2+ ;; stage number is not currently used, but it is taken as a parameter for consistency with the rest of Lib([query :- ::lib.schema/query_stage-number :- :int](into []diff --git a/src/metabase/lib/js.cljs b/src/metabase/lib/js.cljsindex 951520de838..aa098ebb5f0 100644--- a/src/metabase/lib/js.cljs+++ b/src/metabase/lib/js.cljs@@ -29,7 +29,7 @@## Code health- This API surface grew mostly organically during the development of MLv2 and porting the query builder to use it.+ This API surface grew mostly organically during the development of Lib and porting the query builder to use it.The result is that the API is not as systematic or clean as it could be. There are functions which are very specificto a particular use case in one part of the FE, and functions which support legacy compatibility but should be removedas those features are ported.@@ -45,7 +45,7 @@Docs will give an alternative to calling these functions that should cover all cases.Over time, the *Deprecated* functions will be removed, and the *Legacy* ones will become obsolete and get removed as- legacy uses are ported to MLv2.+ legacy uses are ported to Lib.## Display InfoThe library functions typically return opaque CLJS data. We want to hide the library's internals, but we want it to be@@ -105,28 +105,28 @@(lib.core/suggested-name query))(defn ^:export metadataProvider- "Convert the provided metadata container to an MLv2 metadata provider.+ "Convert the provided metadata container to an Lib metadata provider.> **Code health:** Smelly. Name is not idiomatic Clojure.- If the `metadata` is already an MLv2 metadata provider, it is simply returned. If it is a JavaScript `Metadata`- instance, it is wrapped with an MLv2 adapter."+ If the `metadata` is already an Lib metadata provider, it is simply returned. If it is a JavaScript `Metadata`+ instance, it is wrapped with an Lib adapter."[database-id metadata](if (lib.metadata.protocols/metadata-provider? metadata)metadata(js.metadata/metadata-provider database-id metadata)))(defn ^:export query- "Creates an MLv2 query from the provided input: either a table or card metadata, or a legacy MLv1 query in JSON form.+ "Creates an MBQL 5 query from the provided input: either a table or card metadata, or a legacy MLv1 query in JSON form.> **Code health:** Healthy.There are two *arities* for this function:- With two arguments `metadata-provider` and `table-or-card-metadata`, creates an MLv2 query for that table or card.+ With two arguments `metadata-provider` and `table-or-card-metadata`, creates an MBQL 5 query for that table or card.With three arguments `database-id`, `metadata-provider`, and `query-map`, expects the `query-map` to be an MLv1 legacy- query in JSON form. The query is converted to MLv2 form based on the metadata and the provided `database-id` (which is+ query in JSON form. The query is converted to MBQL 5 form based on the metadata and the provided `database-id` (which isnot always included on the `query-map`).<details>@@ -134,7 +134,7 @@Attaches a cache to `metadata-provider` so that subsequent calls with the same `database-id` and `query-map` returnthe same query object.- It would be simpler to attach the MLv2 query to a (non-enumerable) property on the `query-map`, but the `query-map`+ It would be simpler to attach the MBQL 5 query to a (non-enumerable) property on the `query-map`, but the `query-map`might have been `Object.freeze`'d by Immer. So instead we attach a two-level cache to the `metadata-provider`. Theouter key is `database-id`, and the inner cache is a JS `WeakMap`, using the `query-map` itself as the key.This cache is efficient to check, and because it uses a `WeakMap` it does not retain legacy queries if they would@@ -177,10 +177,10 @@:else x))(defn ^:export legacy-query- "Coerce an MLv2 query (MBQL 5 in CLJS data structures) into a legacy MLv1 query in vanilla JSON form.+ "Coerce an Lib 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."+ where a legacy query is still needed. Consider if it's practical to port the consumer of this legacy query to MBQL 5."[query-map](-> (lib.query/->legacy-MBQL query-map)fix-namespaced-values (clj->js :keyword-fn u/qualified-name)))@@ -264,7 +264,7 @@;; - FE calls [[display-info]] in this namespace;; - Which calls [[lib.core/display-info]], defined in `metabase.lib.metadata.calculation`.;; - Which delegates to a *multimethod* `display-info-method`-;; - This has implementations for many different MLv2 values - queries, stages, aggregations, expressions, columns, etc.+;; - This has implementations for many different MBQL 5 values - queries, stages, aggregations, expressions, columns, etc.;;;; These implementations return their info *in CLJS form*, as a map! That's because `display-info` calls are sometimes;; nested, eg. a *column group*'s `display-info` includes the `display-info` for each column in the group.@@ -725,8 +725,8 @@;; There are a few places in the FE where we need to compare two queries, typically to check whether the current;; question has been changed and needs to be saved.-;; **This currently only works for legacy queries in JSON form.** At some point MLv2 queries will become the source of-;; truth, and the format used on the wire. At that point, we'll want a similar comparison for MLv2 queries.+;; **This currently only works for legacy queries in JSON form.** At some point MBQL 5 queries will become the source of+;; truth, and the format used on the wire. At that point, we'll want a similar comparison for MBQL 5 queries.;; TODO: These equality checks only seem to clean and check the last stages - does that really suffice?@@ -1030,7 +1030,7 @@;; Custom expressions are parsed from a string by a TS library, which returns legacy MBQL clauses. That may get ported;; to Clojure someday, but perhaps not - it's quite standalone and there's no use case for that logic in the BE.-;; MLv2 expression clauses are constructed with [[expression-clause]] from an operator and list of args, typically+;; MBQL 5 expression clauses are constructed with [[expression-clause]] from an operator and list of args, typically;; coming from that parser. An expression clause can be attached to a query with `expression`.;; When rendering expressions, the FE calls [[expression-parts]], which returns a kind of AST for the expression.@@ -1313,7 +1313,7 @@(lib.fe-util/join-condition-lhs-or-rhs-column? lhs-or-rhs-expression))(defn ^:export column-metadata?- "Returns true if arg is an MLv2 column, ie. has `:lib/type :metadata/column`.+ "Returns true if arg is an Lib column, ie. has `:lib/type :metadata/column`.> **Code health:** Single use. This is used in the expression editor to parse andformat expression clauses."@@ -1323,7 +1323,7 @@(defn ^:export metric-metadata?"Returns true if arg is named entity that can be used as an aggregation expression on its own, i.e., withoutwrapping it into an aggregating function.- Currently, this can be an MLv2 metric (`:lib/type :metadata/metric`) or an aggregation column+ Currently, this can be an Lib metric (`:lib/type :metadata/metric`) or an aggregation column(`:lib/type :metadata/column` and `:lib/source :source/aggregations`).> **Code health:** Single use. This is used in the expression editor to parse and@@ -1335,7 +1335,7 @@(= (:lib/source arg) :source/aggregations)))))(defn ^:export segment-metadata?- "Returns true if arg is an MLv2 segment, ie. has `:lib/type :metadata/segment`.+ "Returns true if arg is an Lib segment, ie. has `:lib/type :metadata/segment`.> **Code health:** Single use. This is used in the expression editor to parse andformat expression clauses."@@ -1343,7 +1343,7 @@(and (map? arg) (= :metadata/segment (:lib/type arg))))(defn ^:export measure-metadata?- "Returns true if arg is an MLv2 measure, ie. has `:lib/type :metadata/measure`.+ "Returns true if arg is an Lib measure, ie. has `:lib/type :metadata/measure`.> **Code health:** Healthy. This is used in the expression editor to parse andformat expression clauses."@@ -1585,7 +1585,7 @@column))(defn ^:export find-column-indexes-from-legacy-refs- "Given a list of columns (either JS `data.cols` or MLv2 `ColumnMetadata`) and a list of legacy refs, find each ref's+ "Given a list of columns (either JS `data.cols` or Lib `ColumnMetadata`) and a list of legacy refs, find each ref'scorresponding index into the list of columns.Returns a parallel list to the refs, with the corresponding index, or -1 if no matching column is found.@@ -2259,8 +2259,8 @@This properly handles fields, expressions and aggregations.- > **Code health:** Legacy. Avoid new calls. We should refactor the existing callers so they receive MLv2 columns in- the first place, and don't need to convert via to MLv2 via this function."+ > **Code health:** Legacy. Avoid new calls. We should refactor the existing callers so they receive Lib columns in+ the first place, and don't need to convert via to Lib via this function."[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)]@@ -2269,7 +2269,7 @@(defn ^:export legacy-column->type-info"Parses a `legacy-column` into an object compatible with type checking functions. Unlike [[legacy-column->metadata]],- does not require a `query`. MLv2 columns remain unchanged.+ does not require a `query`. Lib columns remain unchanged.> **Code health:** Legacy."[column]diff --git a/src/metabase/lib/js/metadata.cljc b/src/metabase/lib/js/metadata.cljcindex bfc6cf64a4f..8376b87961a 100644--- a/src/metabase/lib/js/metadata.cljc+++ b/src/metabase/lib/js/metadata.cljc@@ -635,5 +635,5 @@:clj (metadata-provider* database-id unparsed-metadata)))(def parse-column- "Parses a JS column provided by the FE into a :metadata/column value for use in MLv2."+ "Parses a JS column provided by the FE into a :metadata/column value for use in Lib."(parse-object-fn :field))diff --git a/src/metabase/lib/ref.cljc b/src/metabase/lib/ref.cljcindex 518a43acf02..725669e078f 100644--- a/src/metabase/lib/ref.cljc+++ b/src/metabase/lib/ref.cljc@@ -9,7 +9,7 @@;;; TODO (Cam 6/12/25) -- update `ref-method` to take an options map instead of needing a dynamic variable for stuff;;; like this.(def ^:dynamic *ref-style*- "The style of field ref to generate -- either the default MLv2-style (`:ref.style/default`) or the broken legacy style+ "The style of field ref to generate -- either the default Lib-style (`:ref.style/default`) or the broken legacy stylereturned by the QP results (`:ref.style/broken-legacy-qp-results`). These broken refs are mostly generated forcompatibility with legacy viz settings maps that used them as keys.":ref.style/default)diff --git a/src/metabase/lib/schema/expression.cljc b/src/metabase/lib/schema/expression.cljcindex 0f4de81ff21..7331731553b 100644--- a/src/metabase/lib/schema/expression.cljc+++ b/src/metabase/lib/schema/expression.cljc@@ -102,7 +102,7 @@(is-type? expr-type base-type)))(def ^:dynamic *suppress-expression-type-check?*- "Set this `true` to skip any type checks for expressions. This is useful while constructing expressions in MLv2 with+ "Set this `true` to skip any type checks for expressions. This is useful while constructing expressions in Lib withfull metadata, but it breaks during legacy conversion in some cases.In particular, if you override the metadata for a column to eg. treat a `:type/Integer` columns as a `:type/Instant`diff --git a/src/metabase/lib/schema/literal.cljc b/src/metabase/lib/schema/literal.cljcindex 374711e171d..b45b7036ec3 100644--- a/src/metabase/lib/schema/literal.cljc+++ b/src/metabase/lib/schema/literal.cljc@@ -135,7 +135,7 @@u.time.impl-common/year-regex]);;; `:effective-type` is required for `:value` clauses. This was not a rule in the legacy MBQL schema, but in actual-;;; usage they basically always have `:base-type`; in MLv2 we're trying to use `:effective-type` everywhere instead;+;;; usage they basically always have `:base-type`; in Lib we're trying to use `:effective-type` everywhere instead;;;; These clauses are useless/pointless without type information anyway, so let's enforce this rule going forward.;;; Conversion can take care of `:base-type` <=> `:effective-type` as needed.(mr/def ::value.optionsdiff --git a/src/metabase/lib/schema/metadata.cljc b/src/metabase/lib/schema/metadata.cljcindex b9b27652d8f..7769eb4da76 100644--- a/src/metabase/lib/schema/metadata.cljc+++ b/src/metabase/lib/schema/metadata.cljc@@ -32,7 +32,7 @@;;; to implement column remapping, e.g. the GUI might display values of `categories.name` when it presents filter;;; options for `venues.category_id` -- you can remap a meaningless integer FK column to something more helpful.;;; 'Human readable values' like these can also be entered manually from the GUI, for example for enum columns. How-;;; will this affect what MLv2 needs to know or does? Not clear at this point, but we'll probably want to abstract+;;; will this affect what Lib needs to know or does? Not clear at this point, but we'll probably want to abstract;;; away dealing with Dimensions in the future so the FE QB GUI doesn't need to special case them.(mr/def ::column.source@@ -80,9 +80,9 @@(def column-has-field-values-options"Possible options for column metadata `:has-field-values`. This is used to determine whether we keep FieldValues for aField (during sync), and which type of widget should be used to pick values of this Field when filtering by it in- the Query Builder. Not otherwise used by MLv2 (except for [[metabase.lib.field/field-values-search-info]], which is+ the Query Builder. Not otherwise used by Lib (except for [[metabase.lib.field/field-values-search-info]], which isa frontend convenience) or QP at the time of this writing. For column remapping purposes in the Query Processor and- MLv2 we just ignore `has_field_values` and only look for FieldValues/Dimension."+ Lib we just ignore `has_field_values` and only look for FieldValues/Dimension.";; AUTOMATICALLY-SET VALUES, SET DURING SYNC;;;; `nil` -- means infer which widget to use based on logic in [[metabase.lib.field/infer-has-field-values]]; thisdiff --git a/src/metabase/lib/schema/parameter.cljc b/src/metabase/lib/schema/parameter.cljcindex ac456f938df..d36cf9af2e8 100644--- a/src/metabase/lib/schema/parameter.cljc+++ b/src/metabase/lib/schema/parameter.cljc@@ -222,7 +222,7 @@;;; These are all legacy-style MBQL clauses FOR NOW, obviously at some point in the future we need to;;; update [[metabase.lib.convert]] to convert `:parameters` back and forth and add UUIDs and what not. But parameters-;;; is not ported to MLv2 yet, so conversion isn't implemented YET.+;;; is not ported to Lib yet, so conversion isn't implemented YET.(mr/def ::target.legacy-field-ref[:ref :metabase.legacy-mbql.schema/field])diff --git a/src/metabase/lib/schema/ref.cljc b/src/metabase/lib/schema/ref.cljcindex 2a51ff5f348..7edbe391289 100644--- a/src/metabase/lib/schema/ref.cljc+++ b/src/metabase/lib/schema/ref.cljc@@ -143,7 +143,7 @@;; Legacy key. Records the temporal unit that was originally on a field ref before it was changed or removed.;; Produced by older queries and the `reconcile-breakout-and-order-by-bucketing` QP middleware. Used as a;; fallback in `nest-breakouts` to determine column granularity when `:temporal-unit` is nil or `:default`.- ;; Not produced by MLv2 code; new queries will not contain this key.+ ;; Not produced by Lib code; new queries will not contain this key.[:original-temporal-unit {:optional true} [:ref ::temporal-bucketing/unit]]]](common/disallowed-keys(into {:strategy ":binning keys like :strategy are not allowed at the top level of :field options."}diff --git a/src/metabase/lib/serialize.cljc b/src/metabase/lib/serialize.cljcindex c881e23083f..97394e6728a 100644--- a/src/metabase/lib/serialize.cljc+++ b/src/metabase/lib/serialize.cljc@@ -1,5 +1,5 @@(ns metabase.lib.serialize- "Logic for preparising an MLv2 query for JSON serialization (for the REST API or app DB). Removes things like+ "Logic for preparising an MBQL 5 query for JSON serialization (for the REST API or app DB). Removes things likeQP-specific keys added during preprocessing."(:require[malli.core :as mc]diff --git a/src/metabase/lib/util.cljc b/src/metabase/lib/util.cljcindex f2cec72c99c..41013b7c340 100644--- a/src/metabase/lib/util.cljc+++ b/src/metabase/lib/util.cljc@@ -275,7 +275,7 @@MBQL 5 query. The key difference is that instead of having a `:query` with a `:source-query` with a `:source-query`and so forth, you have a vector of `:stages` where each stage serves as the source query for the next stage.Initially this was an implementation detail of a few functions, but it's easier to visualize and manipulate, so now- all of MLv2 deals with MBQL 5. See this Slack thread+ all of Lib deals with MBQL 5. See this Slack threadhttps://metaboat.slack.com/archives/C04DN5VRQM6/p1677118410961169?thread_ts=1677112778.742589&cid=C04DN5VRQM6 formore information."[query]@@ -508,7 +508,7 @@(throw (ex-info "Could not convert old :aggregation ref to new UUIDs"{:aggregation &match})))])))-(mu/defn normalized-query-type :- [:maybe [:enum #_MLv2 :mbql/query #_legacy :query :native #_audit :internal]]+(mu/defn normalized-query-type :- [:maybe [:enum #_MBQL5 :mbql/query #_legacy :query :native #_audit :internal]]"Get the `:lib/type` or `:type` from `query`, even if it is not-yet normalized."[query :- [:maybe :map]](when (map? query)diff --git a/src/metabase/lib_be/metadata/jvm.clj b/src/metabase/lib_be/metadata/jvm.cljindex 62ccd30e62f..018d365533c 100644--- a/src/metabase/lib_be/metadata/jvm.clj+++ b/src/metabase/lib_be/metadata/jvm.clj@@ -49,7 +49,7 @@:metadata/column ::lib.schema.metadata/column})(mu/defn instance->metadata- "Convert a (presumably) Toucan 2 instance of an application database model with `snake_case` keys to a MLv2 style+ "Convert a (presumably) Toucan 2 instance of an application database model with `snake_case` keys to a Lib stylemetadata instance with `:lib/type` and `kebab-case` keys."[instance :- :mapmetadata-type :- :keyword]diff --git a/src/metabase/metabot/agent/memory.clj b/src/metabase/metabot/agent/memory.cljindex bc7b3b68133..3b9ee8c9102 100644--- a/src/metabase/metabot/agent/memory.clj+++ b/src/metabase/metabot/agent/memory.clj@@ -55,7 +55,7 @@(defn remember-query"Store a query in memory state by its query-id.- Query should be an MBQL/MLv2 query map."+ Query should be an MBQL 4 (legacy) or MBQL 5 query map."[memory query-id query](update-in memory [:state :queries] assoc query-id query))diff --git a/src/metabase/metabot/agent/streaming.clj b/src/metabase/metabot/agent/streaming.cljindex 18edce858d9..41cd565c2bf 100644--- a/src/metabase/metabot/agent/streaming.clj+++ b/src/metabase/metabot/agent/streaming.clj@@ -24,7 +24,7 @@;;; Query URL Encoding(defn query->url-hash- "Convert an MLv2/MBQL query to a base64-encoded URL hash.+ "Convert an MBQL 4 (legacy) or MBQL 5 query to a base64-encoded URL hash.Used for /question# URLs."[query](-> {:dataset_query query}diff --git a/src/metabase/metabot/agent/user_context.clj b/src/metabase/metabot/agent/user_context.cljindex 38cea4512e9..cfa156e3227 100644--- a/src/metabase/metabot/agent/user_context.clj+++ b/src/metabase/metabot/agent/user_context.clj@@ -78,12 +78,12 @@The frontend sends `type: \"adhoc\"` for *both* notebook (MBQL) and native SQLqueries. We distinguish them by inspecting the query: a dataset-query with- `{:type \"native\"}` (or `:native`) is a native SQL query, as is an MLv2/MBQL 5+ `{:type \"native\"}` (or `:native`) is a native SQL query, as is an MBQL 4 (legacy) or MBQL 5query with a single native stage."[item](let [query (:query item)](or (= "native" (normalize-context-type (:type query)))- ;; MLv2/MBQL 5: normalize and use lib to detect native queries+ ;; MBQL 4/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.cljindex b17bdde67c9..33d9e7ae226 100644--- a/src/metabase/metabot/context.clj+++ b/src/metabase/metabot/context.clj@@ -160,8 +160,8 @@[])))(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/MBQL 5 and legacy formats."+ "Given a context item with an MBQL query, return [database-id [table-id ...]] if it has source-table references, or+ nil otherwise. Handles both MBQL 4 (legacy) and MBQL 5 formats."[item](when (= "adhoc" (:type item))(let [query (:query item)diff --git a/src/metabase/metabot/tools/charts/create.clj b/src/metabase/metabot/tools/charts/create.cljindex 63cf154e005..ba00cb193b4 100644--- a/src/metabase/metabot/tools/charts/create.clj+++ b/src/metabase/metabot/tools/charts/create.clj@@ -16,7 +16,7 @@:progress :funnel :object :map})(defn- query->url-hash- "Convert an MLv2/MBQL query to a base64-encoded URL hash."+ "Convert an MBQL 4 (legacy) or MBQL 5 query to a base64-encoded URL hash."[query]#_{:clj-kondo/ignore [:discouraged-var]}(let [dataset-query (if (and (map? query) (:lib/type query))diff --git a/src/metabase/metabot/tools/filters.clj b/src/metabase/metabot/tools/filters.cljindex 9c76d56c34b..fcb8b5de38f 100644--- a/src/metabase/metabot/tools/filters.clj+++ b/src/metabase/metabot/tools/filters.clj@@ -20,7 +20,7 @@;;; URL Generation for Auto-Navigation(defn- query->url-hash- "Convert an MLv2/MBQL query to a base64-encoded URL hash."+ "Convert an MBQL 4 (legacy) or MBQL 5 query to a base64-encoded URL hash."[query]#_{:clj-kondo/ignore [:discouraged-var]}(let [dataset-query (if (and (map? query) (:lib/type query))diff --git a/src/metabase/queries/models/card.clj b/src/metabase/queries/models/card.cljindex 005d6a97489..e1f1b9dc9f3 100644--- a/src/metabase/queries/models/card.clj+++ b/src/metabase/queries/models/card.clj@@ -366,7 +366,7 @@(when table-id{:table_id table-id}))))))))-;;; TODO -- move this to [[metabase.query-processor.card]] or MLv2 so the logic can be shared between the backend and+;;; TODO -- move this to [[metabase.query-processor.card]] or Lib so the logic can be shared between the backend and;;; frontend (?);;;;;; NOTE: this should mirror `getTemplateTagParameters` in frontend/src/metabase-lib/parameters/utils/template-tags.tsdiff --git a/src/metabase/query_processor/metadata.clj b/src/metabase/query_processor/metadata.cljindex 886621366b1..08f83ec80cd 100644--- a/src/metabase/query_processor/metadata.clj+++ b/src/metabase/query_processor/metadata.clj@@ -76,14 +76,14 @@(driver/query-result-metadata driver query)))(mu/defn- add-extra-column-metadata :- :map- [col :- :map- legacy-or-mlv2 :- [:enum ::legacy ::mlv2]]- (let [display-name-key (case legacy-or-mlv2+ [col :- :map+ legacy-or-lib :- [:enum ::legacy ::lib]]+ (let [display-name-key (case legacy-or-lib::legacy :display_name- ::mlv2 :display-name)- semantic-type-key (case legacy-or-mlv2+ ::lib :display-name)+ semantic-type-key (case legacy-or-lib::legacy :semantic_type- ::mlv2 :semantic-type)]+ ::lib :semantic-type)](letfn [(ensure-display-name [col](cond-> col;; I'm trying to disable nice display name humanization because it breads like 100 Cypress tests and I@@ -93,7 +93,7 @@(assoc display-name-key (:name col) #_(u.humanization/name->human-readable-name :simple (:name col)))))(infer-semantic-type-by-name [col](let [legacy-col (cond-> col- (= legacy-or-mlv2 ::mlv2)+ (= legacy-or-lib ::lib)(perf/update-keys u/->snake_case_en))semantic-type (analyze/infer-semantic-type-by-name legacy-col)](merge col@@ -116,7 +116,7 @@to run the query. In this case, `current-user-id` is used so we can associate that information with the query that isrun.- Returns columns as MLv2-style `kebab-case` column metadata; for legacy metadata you can use [[legacy-result-metadata]]+ Returns columns as Lib-style `kebab-case` column metadata; for legacy metadata you can use [[legacy-result-metadata]]instead."([query](result-metadata query nil))@@ -127,7 +127,7 @@(fn [col](-> col(lib-be/instance->metadata :metadata/column)- (add-extra-column-metadata ::mlv2)))+ (add-extra-column-metadata ::lib)))(result-metadata* query current-user-id))))(mu/defn- ensure-legacy :- ::qp.schema/result-metadata.column@@ -145,8 +145,8 @@(->> (lib/normalize ::qp.schema/result-metadata.column)))))(mu/defn legacy-result-metadata :- [:maybe ::qp.schema/result-metadata.columns]- "Like [[result-metadata]], but return metadata in legacy format rather than MLv2 format. This should be considered- deprecated, as we're working on moving towards using MLv2-style metadata everywhere; avoid new usages of this function+ "Like [[result-metadata]], but return metadata in legacy format rather than Lib format. This should be considered+ deprecated, as we're working on moving towards using Lib-style metadata everywhere; avoid new usages of this functionif possible, and prefer [[result-metadata]] instead.Note: it is preferable to use [[metabase.lib.core/lib-metadata-column->legacy-metadata-column]] directly if you reallydiff --git a/src/metabase/query_processor/middleware/annotate.clj b/src/metabase/query_processor/middleware/annotate.cljindex 441bd042c1f..4d94cda0cb2 100644--- a/src/metabase/query_processor/middleware/annotate.clj+++ b/src/metabase/query_processor/middleware/annotate.clj@@ -156,7 +156,7 @@;;;;;;; These are only for convenience for drivers that used to use stuff in annotate directly -- we can remove it once we-;;; convert drivers to MLv2+;;; convert drivers to MBQL 5.(p/import-vars[metabase.query-processor.middleware.annotate.legacy-helper-fnsaggregation-namediff --git a/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.clj b/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.cljindex 602c6edbf7d..f4e87fa0175 100644--- a/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.clj+++ b/src/metabase/query_processor/middleware/annotate/legacy_helper_fns.clj@@ -1,9 +1,9 @@(ns metabase.query-processor.middleware.annotate.legacy-helper-fns- "Helper functions that used to live in the old implementation of [[metabase.query-processor.middleware.annotate]]- that no longer do since we rewrote it to use MLv2. These were used by various drivers for various nefarious purposes.+ "Helper functions that used to live in the old implementation of [[metabase.query-processor.middleware.annotate]] that+ no longer do since we rewrote it to use Lib. These were used by various drivers for various nefarious purposes.- I'm keeping them around for now so drivers can continue to use them until we work on converting drivers to MLv2 (at- which point they can use MLv2 directly)."+ I'm keeping them around for now so drivers can continue to use them until we work on converting drivers to MBQL+ 5 (at which point they can use Lib directly)."(:require;; existing legacy usage -- don't use legacy MBQL namespaces in QP going forward^{:clj-kondo/ignore [:discouraged-namespace]} [metabase.legacy-mbql.normalize :as mbql.normalize]@@ -19,7 +19,7 @@[metabase.util.malli :as mu]))(mu/defn legacy-inner-query->mbql5-query :- ::lib.schema/query- "Convert a legacy `inner-query` to an MLv2 query. Requires bound QP store."+ "Convert a legacy `inner-query` to an MBQL 5 query. Requires bound QP store."{:deprecated "0.57.0"}[inner-query :- [:and:map@@ -28,7 +28,7 @@(some-fn :query :source-table :source-query)]]];; existing usage -- don't use going forward#_{:clj-kondo/ignore [:deprecated-var]}- (qp.store/cached [:mlv2-query (hash inner-query)]+ (qp.store/cached [:mbql5-query (hash inner-query)](try(lib/query-from-legacy-inner-query(qp.store/metadata-provider)@@ -60,11 +60,11 @@this namespace."[legacy-query {initial-cols :cols, :as _initial-metadata} :- [:maybe :map]](let [expected-cols (requiring-resolve 'metabase.query-processor.middleware.annotate/expected-cols)- mlv2-query (lib/query+ mbql5-query (lib/query(qp.store/metadata-provider);; if this query has a `:native` query added to it already then remove that so we don't get;; schema validation errors(cond-> legacy-query((every-pred :native :query) legacy-query)(dissoc :native)))]- (expected-cols mlv2-query initial-cols)))+ (expected-cols mbql5-query initial-cols)))diff --git a/src/metabase/query_processor/middleware/parameters.clj b/src/metabase/query_processor/middleware/parameters.cljindex bd5676c0541..d127a2bef7c 100644--- a/src/metabase/query_processor/middleware/parameters.clj+++ b/src/metabase/query_processor/middleware/parameters.clj@@ -132,7 +132,7 @@;; TODO: Native models should be within scope of dashboard filters, by applying the filter on an outer stage.;; That doesn't work, so the logic below requires MBQL queries only to fix the regression.;; Native models don't actual get filtered even when linked to dashboard filters, but that's not a regression.- ;; This can be fixed properly once this middleware is powered by MLv2. See #40011.+ ;; This can be fixed properly once this middleware is powered by Lib. See #40011.(and (seq parameters)(:metadata/model-metadata info)(not (lib/native-stage? (lib/query-stage query -1))))diff --git a/src/metabase/query_processor/pivot.clj b/src/metabase/query_processor/pivot.cljindex 848bbafcb98..c0f8295102e 100644--- a/src/metabase/query_processor/pivot.clj+++ b/src/metabase/query_processor/pivot.clj@@ -379,7 +379,7 @@show-column-totals (get viz-settings "pivot.show_column_totals" true)metadata-provider (or (:lib/metadata query)(lib-be/application-database-metadata-provider (:database query)))- mlv2-query (lib/query metadata-provider query)+ mbql5-query (lib/query metadata-provider query)breakouts (into [](map-indexed (fn [i col](cond-> col@@ -389,12 +389,12 @@;; match a column that has a join-alias but whose source is a;; model(contains? col :lib/card-id) (assoc :lib/source :source/card))))- (concat (lib/breakouts-metadata mlv2-query)- (lib/aggregations-metadata mlv2-query)))+ (concat (lib/breakouts-metadata mbql5-query)+ (lib/aggregations-metadata mbql5-query)))index-in-breakouts (fn index-in-breakouts [legacy-ref](try(::idx (lib.equality/find-column-for-legacy-ref- mlv2-query+ mbql5-query-1legacy-refbreakouts))diff --git a/src/metabase/query_processor/store.clj b/src/metabase/query_processor/store.cljindex 776440cad21..db3d6db1bda 100644--- a/src/metabase/query_processor/store.clj+++ b/src/metabase/query_processor/store.clj@@ -219,7 +219,7 @@;;;;(mu/defn ->legacy-metadata- "For compatibility: convert MLv2-style metadata as returned by [[metabase.lib.metadata.protocols]]+ "For compatibility: convert Lib-style metadata as returned by [[metabase.lib.metadata.protocols]]or [[metabase.lib.metadata]] functions(with `kebab-case` keys and `:lib/type`) to legacy QP/application database style metadata (with `snake_case` keysand Toucan 2 model `:type` metadata).diff --git a/src/metabase/query_processor/util/add_alias_info.clj b/src/metabase/query_processor/util/add_alias_info.cljindex 41d8b34ffc1..d3d035a9b37 100644--- a/src/metabase/query_processor/util/add_alias_info.clj+++ b/src/metabase/query_processor/util/add_alias_info.clj@@ -69,16 +69,6 @@s :- :string](driver/escape-alias driver s))-(defmulti ^String field-reference-mlv2- "Generate a reference for the field instance `field-inst` appropriate for the driver `driver`.- By default this is just the name of the field, but it can be more complicated, e.g., take- parent fields into account.-- DEPRECATED in 0.56.0, and no longer used."- {:added "0.48.0", :deprecated "0.57.0, " :arglists '([driver field-inst])}- driver/dispatch-on-initialized-driver- :hierarchy #'driver/hierarchy)-(defn- escape-fn []{:pre [(keyword? driver/*driver*)]}(let [f (lib/unique-name-generator)diff --git a/src/metabase/types/core.cljc b/src/metabase/types/core.cljcindex dc542cc87e4..bab411fe1a9 100644--- a/src/metabase/types/core.cljc+++ b/src/metabase/types/core.cljc@@ -377,7 +377,7 @@;;; ---------------------------------------------------- Util Fns ----------------------------------------------------(mr/def ::snake-cased-type-info- "E.g. the version coming back from the app DB as opposed to MLv2 metadata. This should eventually be considered+ "E.g. the version coming back from the app DB as opposed to Lib metadata. This should eventually be considereddeprecated."[:map[:base_type :any]])diff --git a/src/metabase/upload/impl.clj b/src/metabase/upload/impl.cljindex b3df744d201..35b026094b0 100644--- a/src/metabase/upload/impl.clj+++ b/src/metabase/upload/impl.clj@@ -755,7 +755,7 @@(filter (comp #{(:id table)} only-table-id))(map :id)seq)]- ;; Ideally we would do all the filtering in the query, but this would not allow us to leverage mlv2.+ ;; Ideally we would do all the filtering in the query, but this would not allow us to leverage Lib.(model-persistence/invalidate! {:card_id [:in model-ids]});; Also refresh the metadata, so that newly added columns are visible, and types are updated.(doseq [id model-ids]diff --git a/src/metabase/util/snake_hating_map.clj b/src/metabase/util/snake_hating_map.cljindex 2762557a6a5..ed3aa3b5d62 100644--- a/src/metabase/util/snake_hating_map.clj+++ b/src/metabase/util/snake_hating_map.clj@@ -2,7 +2,7 @@"This is a map type that catches attempts to get `:snake_case` values from it. In prod, it logs a warning and gets thevalue for the equivalent `kebab-case` key; in tests and dev it throws an Exception.- This is here so we can catch driver code that needs to be updated in 48+ to use MLv2 metadata rather than Toucan+ This is here so we can catch driver code that needs to be updated in 48+ to use Lib metadata rather than Toucaninstances. After 51 we can remove this, everything should be updated by then."(:require[clojure.string :as str]@@ -75,12 +75,12 @@(defn snake-hating-map"Create a new map that handles either `snake_case` or `kebab-case` keys, but warns is you use `snake_case`keys (in prod) or throws an Exception (in dev and tests). This is here so we can catch code that needs to be updated- to use MLv2 metadata in 48+."+ to use Lib metadata in 48+."([](snake-hating-map {}))([m](-> (or m {})- (vary-meta assoc :metabase.driver/metadata-type :metabase.driver/metadata-type.mlv2)+ (vary-meta assoc :metabase.driver/metadata-type :metabase.driver/metadata-type.lib)->SnakeHatingMap))([k v & more](snake-hating-map (into {k v} (partition-all 2) more))))diff --git a/test/metabase/dashboards_rest/api_test.clj b/test/metabase/dashboards_rest/api_test.cljindex 66ffe8c6576..57aecb150af 100644--- a/test/metabase/dashboards_rest/api_test.clj+++ b/test/metabase/dashboards_rest/api_test.clj@@ -3545,14 +3545,14 @@(is (some? (mt/user-http-request :rasta :get 200 (chain-filter-search-url dashboard-id "abc" "red")))))))))(deftest parameter-values-from-card-test-4- ;; TODO: Re-enable this test, or delete it. Now that mapping dashboard filters to fields on cards is powered by MLv2,+ ;; TODO: Re-enable this test, or delete it. Now that mapping dashboard filters to fields on cards is powered by Lib,;; the FE does not use the /api/table/:card__id/query_metadata API call to determine the fields which can be filtered;; on a saved question. It uses `Lib.filterableColumns` instead, which given a saved question with aggregations in the;; last stage will return the pre-aggregation columns on that last stage. That allows linking the dashboard filter not;; to the aggregations and breakouts, but to the pre-aggregation columns which feed into the aggregations.;; This is typically what's wanted for filtering an aggregated query in a dashboard: filtering SUM(subtotal) to a;; time range, product category, etc.- ;; This test should either (1) be rehabilitated to use MLv2 to get the set of columns for filtering a dashcard (like+ ;; This test should either (1) be rehabilitated to use Lib to get the set of columns for filtering a dashcard (like;; the FE); or (2) just be dropped if it's not providing value.#_(testing "field selection should compatible with field-id from /api/table/:card__id/query_metadata";; FE use the id returned by /api/table/:card__id/query_metadata@@ -4681,9 +4681,9 @@:email-body-pattern "href=":match-email-body-pattern? false})))-(deftest run-mlv2-dashcard-query-test+(deftest run-mbql5-dashcard-query-test(testing "POST /api/dashboard/:dashboard-id/dashcard/:dashcard-id/card/:card-id"- (testing "Should be able to run a query for a DashCard with an MLv2 query (#39024)"+ (testing "Should be able to run a query for a DashCard with an 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)diff --git a/test/metabase/driver/connection_test.clj b/test/metabase/driver/connection_test.cljindex c24c00ff064..bc257e96549 100644--- a/test/metabase/driver/connection_test.clj+++ b/test/metabase/driver/connection_test.clj@@ -26,7 +26,7 @@(let [details {:host "read-host" :port 5432}write-data-details {:host "write-host" :port 5432}](testing "effective-details returns write_data_details when :write-data and details exist"- (testing "with kebab-case key (MLv2 metadata style)"+ (testing "with kebab-case key (Lib metadata style)"(let [database {:lib/type :metadata/database:details details:write-data-details write-data-details}]diff --git a/test/metabase/lib/card_test.cljc b/test/metabase/lib/card_test.cljcindex 9ad551f1555..f556ef8cdc9 100644--- a/test/metabase/lib/card_test.cljc+++ b/test/metabase/lib/card_test.cljc@@ -308,16 +308,16 @@[{:keys [result-metadata-style result-metadata-fn]}](let [result-metadata-fn (or result-metadata-fn(case result-metadata-style- ::mlv2-returned-columns lib.metadata.calculation/returned-columns- ::mlv2-expected-columns lib.metadata.result-metadata/returned-columns- ::legacy-snake-case-qp (mu/fn :- [:sequential :map]- [query]- (for [col (lib.metadata.result-metadata/returned-columns query)]- (-> col- (update-keys (fn [k]- (cond-> k- (simple-keyword? k) u/->snake_case_en)))- (dissoc :lib/type))))))]+ ::lib-returned-columns lib.metadata.calculation/returned-columns+ ::lib-expected-columns lib.metadata.result-metadata/returned-columns+ ::legacy-snake-case-qp (mu/fn :- [:sequential :map]+ [query]+ (for [col (lib.metadata.result-metadata/returned-columns query)]+ (-> col+ (update-keys (fn [k]+ (cond-> k+ (simple-keyword? k) u/->snake_case_en)))+ (dissoc :lib/type))))))](as-> meta/metadata-provider mp(lib.tu/mock-metadata-providermp@@ -361,7 +361,7 @@;;; adapted from [[metabase.queries-rest.api.card-test/model-card-test-2]](deftest ^:parallel preserve-edited-metadata-test(testing "Cards preserve their edited metadata"- (doseq [result-metadata-style [::mlv2-returned-columns ::mlv2-expected-columns ::legacy-snake-case-qp]]+ (doseq [result-metadata-style [::lib-returned-columns ::lib-expected-columns ::legacy-snake-case-qp]](testing (str "result metadata style = " (name result-metadata-style))(let [mp (preserve-edited-metadata-test-mock-metadata-provider {:result-metadata-style result-metadata-style})](letfn [(only-user-edits [col]diff --git a/test/metabase/lib/expression_test.cljc b/test/metabase/lib/expression_test.cljcindex 6896795b374..b9f2adaff7b 100644--- a/test/metabase/lib/expression_test.cljc+++ b/test/metabase/lib/expression_test.cljc@@ -268,7 +268,7 @@(->> (map (fn [expr] (lib/display-info (lib.tu/venues-query) expr))))))));; TODO: This logic was removed as part of fixing #39059. We might want to bring it back for collisions with other;; expressions in the same stage; probably not with tables or earlier stages. De-duplicating names is supported by the- ;; QP code, and it should be powered by MLv2 in due course.+ ;; QP code, and it should be powered by Lib in due course.#_(testing "collisions with other column names are detected and rejected"(let [query (lib/query meta/metadata-provider (meta/table-metadata :categories))ex (trydiff --git a/test/metabase/lib/field_test.cljc b/test/metabase/lib/field_test.cljcindex 74b956cf2bb..d3ad386fa79 100644--- a/test/metabase/lib/field_test.cljc+++ b/test/metabase/lib/field_test.cljc@@ -2364,23 +2364,23 @@(lib.tu.notebook/add-breakout {:display-name "Summaries"} {:display-name "Created At: Year"} {}))))))(deftest ^:parallel display-info-propagate-join-aliases-test- (let [mp (lib.tu/mock-metadata-provider- meta/metadata-provider- {:cards [{:id 1- :dataset-query (lib.tu.macros/mbql-query venues- {:joins- [{:source-table $$categories- :condition [:= $category-id &c.categories.id]- :fields :all- :alias "c"}]})}]})- query {:database (meta/id)- :type :query- :query {:source-table "card__1"}}- mlv2-query (lib/query mp query)- breakouts (lib/breakoutable-columns mlv2-query)- agg-query (-> mlv2-query- (lib/breakout (second breakouts))- (lib/breakout (last breakouts)))]+ (let [mp (lib.tu/mock-metadata-provider+ meta/metadata-provider+ {:cards [{:id 1+ :dataset-query (lib.tu.macros/mbql-query venues+ {:joins+ [{:source-table $$categories+ :condition [:= $category-id &c.categories.id]+ :fields :all+ :alias "c"}]})}]})+ query {:database (meta/id)+ :type :query+ :query {:source-table "card__1"}}+ mbql5-query (lib/query mp query)+ breakouts (lib/breakoutable-columns mbql5-query)+ agg-query (-> mbql5-query+ (lib/breakout (second breakouts))+ (lib/breakout (last breakouts)))](testing "display name should be correct; inherited column status has to be detected correctly for this to work"(is (= [["Name" true] ; they're both inherited!["c → Name" true]]diff --git a/test/metabase/lib/schema/expression/conditional_test.cljc b/test/metabase/lib/schema/expression/conditional_test.cljcindex a752ffe3b97..ae578c0da77 100644--- a/test/metabase/lib/schema/expression/conditional_test.cljc+++ b/test/metabase/lib/schema/expression/conditional_test.cljc@@ -52,7 +52,7 @@(deftest ^:parallel case-type-of-test(testing "type-of logic for :case expressions"- ;; In QP and MLv2: `expression/type-of-method :case`+ ;; In QP and Lib: `expression/type-of-method :case`(are [expr expected] (= expected(expression/type-of expr))@@ -133,7 +133,7 @@(deftest ^:parallel coalesce-type-of-test(testing "type-of logic for :coalesce expressions"- ;; In QP and MLv2: `expression/type-of-method :case`+ ;; In QP and Lib: `expression/type-of-method :case`(are [expr expected] (= expected(expression/type-of expr))diff --git a/test/metabase/lib/test_util/macros.clj b/test/metabase/lib/test_util/macros.cljindex d6127f41e87..53e92493d33 100644--- a/test/metabase/lib/test_util/macros.clj+++ b/test/metabase/lib/test_util/macros.clj@@ -15,7 +15,7 @@(thunk)))(defmacro $ids- "MLv2 version of [[metabase.test/$ids]] that uses the [[metabase.lib.test-metadata]] rather than the application+ "MBQL 5 version of [[metabase.test/$ids]] that uses the [[metabase.lib.test-metadata]] rather than the applicationdatabase."{:style/indent :defn}([form]@@ -27,8 +27,8 @@;;; TODO (Cam 6/13/25) -- rename this `mbql-4-query` or something so it's clear that it returns a legacy MBQL query and;;; not MBQL 5(defmacro mbql-query- "MLv2 version of [[metabase.test/mbql-query]] that uses the [[metabase.lib.test-metadata]] rather than the application- database."+ "MBQL 5 version of [[metabase.test/mbql-query]] that uses the [[metabase.lib.test-metadata]] rather than the+ application database."{:style/indent :defn}([table-name]`(mbql-query ~table-name {}))diff --git a/test/metabase/lib/test_util/mocks_31368.cljc b/test/metabase/lib/test_util/mocks_31368.cljcindex 9ddb1684a67..f9626117ee8 100644--- a/test/metabase/lib/test_util/mocks_31368.cljc+++ b/test/metabase/lib/test_util/mocks_31368.cljc@@ -1,5 +1,5 @@(ns metabase.lib.test-util.mocks-31368- "Repro for `[MLv2] Handle MLv1 field references for columns from questions/models in MLv2` (#31368)"+ "Repro for `[Lib] Handle MLv1-generated field references for columns from questions/models in Lib` (#31368)"(:require[metabase.lib.core :as lib][metabase.lib.metadata :as lib.metadata]@@ -28,7 +28,7 @@(str (:lib/original-join-alias col) " → " display-name))))))(defn query-with-legacy-source-card- "An MLv2 query that has a `:source-card` that has a legacy query, and legacy metadata."+ "An MBQL 5 query that has a `:source-card` that has a legacy query, and legacy metadata."([has-result-metadata?](query-with-legacy-source-card has-result-metadata? :question))([has-result-metadata? card-type]diff --git a/test/metabase/lib/test_util/mocks_31769.cljc b/test/metabase/lib/test_util/mocks_31769.cljcindex 89b66da6ece..369ee6684c6 100644--- a/test/metabase/lib/test_util/mocks_31769.cljc+++ b/test/metabase/lib/test_util/mocks_31769.cljc@@ -1,5 +1,5 @@(ns metabase.lib.test-util.mocks-31769- "Mocks to reproduce the behavior of e2e test #31769 directly in MLv2 and in QP tests. Some tests using this:+ "Mocks to reproduce the behavior of e2e test #31769 directly in Lib and in QP tests. Some tests using this:* [[metabase.lib.card-test/returned-columns-31769-test]]* [[metabase.lib.join-test/join-source-card-with-in-previous-stage-with-joins-test]]diff --git a/test/metabase/lib_be/metadata/jvm_test.clj b/test/metabase/lib_be/metadata/jvm_test.cljindex 61db5238e78..f18a28494f3 100644--- a/test/metabase/lib_be/metadata/jvm_test.clj+++ b/test/metabase/lib_be/metadata/jvm_test.clj@@ -45,17 +45,17 @@(lib.metadata.calculation/returned-columns query)))))(deftest ^:parallel join-with-aggregation-reference-in-fields-metadata-test- (let [query (mt/mbql-query products- {:joins [{:source-query {:source-table $$orders- :breakout [$orders.product_id]- :aggregation [[:sum $orders.quantity]]}- :alias "Orders"- :condition [:= $id &Orders.orders.product_id]- :fields [&Orders.orders.product_id- &Orders.*sum/Integer]}]- :fields [$id]})- mlv2-query (lib/query (mt/metadata-provider)- (lib.convert/->mbql5 query))]+ (let [query (mt/mbql-query products+ {:joins [{:source-query {:source-table $$orders+ :breakout [$orders.product_id]+ :aggregation [[:sum $orders.quantity]]}+ :alias "Orders"+ :condition [:= $id &Orders.orders.product_id]+ :fields [&Orders.orders.product_id+ &Orders.*sum/Integer]}]+ :fields [$id]})+ mbql5-query (lib/query (mt/metadata-provider)+ (lib.convert/->mbql5 query))](is (=? [{:base-type :type/BigInteger:semantic-type :type/PK:table-id (mt/id :products)@@ -66,30 +66,30 @@:id (mt/id :products :id):lib/desired-column-alias "ID":display-name "ID"}- {:lib/join-alias "Orders"- :base-type :type/Integer- :semantic-type :type/FK- :table-id (mt/id :orders)- :name "PRODUCT_ID"- :lib/source :source/joins- :lib/source-column-alias "PRODUCT_ID"- :effective-type :type/Integer- :id (mt/id :orders :product_id)- :lib/desired-column-alias "Orders__PRODUCT_ID"- :display-name "Orders → Product ID"- :lib/original-join-alias "Orders"}- {:lib/join-alias "Orders"- :lib/type :metadata/column- :base-type :type/Integer- :name "sum"- :lib/source :source/joins- :lib/source-column-alias "sum"- :effective-type :type/Integer- :lib/desired-column-alias "Orders__sum"- :display-name "Orders → Sum of Quantity"- :lib/original-join-alias "Orders"}]+ {:lib/join-alias "Orders"+ :base-type :type/Integer+ :semantic-type :type/FK+ :table-id (mt/id :orders)+ :name "PRODUCT_ID"+ :lib/source :source/joins+ :lib/source-column-alias "PRODUCT_ID"+ :effective-type :type/Integer+ :id (mt/id :orders :product_id)+ :lib/desired-column-alias "Orders__PRODUCT_ID"+ :display-name "Orders → Product ID"+ :lib/original-join-alias "Orders"}+ {:lib/join-alias "Orders"+ :lib/type :metadata/column+ :base-type :type/Integer+ :name "sum"+ :lib/source :source/joins+ :lib/source-column-alias "sum"+ :effective-type :type/Integer+ :lib/desired-column-alias "Orders__sum"+ :display-name "Orders → Sum of Quantity"+ :lib/original-join-alias "Orders"}](binding [lib.metadata.calculation/*display-name-style* :long]- (lib.metadata.calculation/returned-columns mlv2-query))))))+ (lib.metadata.calculation/returned-columns mbql5-query))))))(deftest ^:synchronized with-temp-source-question-metadata-test#_{:clj-kondo/ignore [:discouraged-var]}@@ -103,10 +103,10 @@(let [query {:database (mt/id):type :query:query {:source-card (u/the-id card)}}- mlv2-query (lib/query (mt/metadata-provider)- (lib.convert/->mbql5 query))- breakouts (lib/breakoutable-columns mlv2-query)- agg-query (-> mlv2-query+ mbql5-query (lib/query (mt/metadata-provider)+ (lib.convert/->mbql5 query))+ breakouts (lib/breakoutable-columns mbql5-query)+ agg-query (-> mbql5-query(lib/breakout (second breakouts))(lib/breakout (peek breakouts)))](is (=? [{:display-name "ID"@@ -141,8 +141,8 @@:long-display-name "c → Name":effective-type :type/Text:semantic-type :type/Name}]- (map #(lib/display-info mlv2-query %)- (lib.metadata.calculation/returned-columns mlv2-query))))+ (map #(lib/display-info mbql5-query %)+ (lib.metadata.calculation/returned-columns mbql5-query))))(is (= ["Name""c → Name"](map :display-name (lib.metadata.calculation/returned-columns agg-query))))diff --git a/test/metabase/queries/models/card_test.clj b/test/metabase/queries/models/card_test.cljindex 35737dc5154..e31aff88cd2 100644--- a/test/metabase/queries/models/card_test.clj+++ b/test/metabase/queries/models/card_test.clj@@ -858,8 +858,8 @@t/offset-date-time(.withNano 0)))))))-(deftest save-mlv2-card-test- (testing "App DB CRUD should work for a Card with an MLv2 query (#39024)"+(deftest save-mbql5-card-test+ (testing "App DB CRUD should work for a Card with an 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)]@@ -872,7 +872,7 @@:table_id (mt/id :venues):database_id (mt/id)}card)))- (testing "Save to app DB: Check MLv2 query was serialized to app DB in a sane way. Metadata provider should be removed"+ (testing "Save to app DB: Check MBQL 5 query was serialized to app DB in a sane way. Metadata provider should be removed"(is (= {"lib/type" "mbql/query""database" (mt/id)"stages" [{"lib/type" "mbql.stage/mbql"diff --git a/test/metabase/queries_rest/api/card_test.clj b/test/metabase/queries_rest/api/card_test.cljindex c5e5e2f073b..0b40eedc84b 100644--- a/test/metabase/queries_rest/api/card_test.clj+++ b/test/metabase/queries_rest/api/card_test.clj@@ -3730,9 +3730,9 @@(fn [card](mt/user-http-request :crowberto :get 200 (str "card/" (:id card))))))-(deftest save-mlv2-card-test+(deftest save-mbql5-card-test(testing "POST /api/card"- (testing "Should be able to save a Card with an MLv2 query (#39024)"+ (testing "Should be able to save a Card with an MBQL 5 query (#39024)"(mt/with-model-cleanup [:model/Card](let [metadata-provider (mt/metadata-provider)venues (lib.metadata/table metadata-provider (mt/id :venues))@@ -3749,9 +3749,9 @@:source-table (mt/id :venues)}]}}response)))))))-(deftest ^:parallel run-mlv2-card-query-test+(deftest ^:parallel run-mbql5-card-query-test(testing "POST /api/card/:id/query"- (testing "Should be able to run a query for a Card with an MLv2 query (#39024)"+ (testing "Should be able to run a query for a Card with an 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)diff --git a/test/metabase/query_processor/api_test.clj b/test/metabase/query_processor/api_test.cljindex b1d927d4d3d..14abfb9749b 100644--- a/test/metabase/query_processor/api_test.clj+++ b/test/metabase/query_processor/api_test.clj@@ -945,9 +945,9 @@(is (= ["A sian" "As"](mt/user-http-request :crowberto :post 200 "dataset/parameter/remapping" body))))))-(deftest ^:parallel adhoc-mlv2-query-test+(deftest ^:parallel adhoc-mbql5-query-test(testing "POST /api/dataset"- (testing "Should be able to run an ad-hoc MLv2 query (#39024)"+ (testing "Should be able to run an ad-hoc 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)@@ -957,9 +957,9 @@[2 "Stout Burgers & Beers" 11 34.0996 -118.329 2]]}}(mt/user-http-request :crowberto :post 202 "dataset" query)))))))-(deftest ^:parallel mlv2-query-convert-to-native-test+(deftest ^:parallel mbql5-query-convert-to-native-test(testing "POST /api/dataset/native"- (testing "Should be able to convert an MLv2 query to native (#39024)"+ (testing "Should be able to convert an MBQL 5 query to native (#39024)"(let [metadata-provider (mt/metadata-provider)venues (lib.metadata/table metadata-provider (mt/id :venues))query (-> (lib/query metadata-provider venues)@@ -986,9 +986,9 @@(driver/prettify-native-form :h2)str/split-lines))))))))))-(deftest ^:parallel mlv2-query-convert-to-native-disable-default-limit-test+(deftest ^:parallel mbql5-query-convert-to-native-disable-default-limit-test(testing "POST /api/dataset/native"- (testing "MLv2 query with disable-default-limit should compile to SQL without a LIMIT clause"+ (testing "MBQL 5 query with disable-default-limit should compile to SQL without a LIMIT clause"(let [metadata-provider (mt/metadata-provider)venues (lib.metadata/table metadata-provider (mt/id :venues))query (-> (lib/query metadata-provider venues)diff --git a/test/metabase/query_processor/explicit_joins_test.clj b/test/metabase/query_processor/explicit_joins_test.cljindex 0428a010f1d..6c8c0f1fc5a 100644--- a/test/metabase/query_processor/explicit_joins_test.clj+++ b/test/metabase/query_processor/explicit_joins_test.clj@@ -1099,8 +1099,8 @@[str str u.date/temporal-str->iso8601-str 2.0 4.0](qp/process-query query))))))))-(deftest ^:parallel mlv2-references-in-join-conditions-test- (testing "Make sure join conditions that contain MLv2-generated refs with extra info like `:base-type` work correctly (#33083)"+(deftest ^:parallel mbql5-references-in-join-conditions-test+ (testing "Make sure join conditions that contain Lib-generated refs with extra info like `:base-type` work correctly (#33083)"(qp.store/with-metadata-provider (qp.test-util/metadata-provider-with-cards-for-queries[(mt/mbql-query reviews{:joins [{:source-table $$products@@ -1142,7 +1142,7 @@;;; see also [[metabase.query-processor.preprocess-test/test-31769]](deftest ^:parallel test-31769- (testing "Make sure queries built with MLv2 that have source Cards with joins work correctly (#31769) (#33083)"+ (testing "Make sure queries built with Lib that have source Cards with joins work correctly (#31769) (#33083)"(let [metadata-provider (lib.tu.mocks-31769/mock-metadata-provider(mt/metadata-provider)mt/id)]diff --git a/test/metabase/query_processor/implicit_joins_test.clj b/test/metabase/query_processor/implicit_joins_test.cljindex 3143a248d59..f400a307575 100644--- a/test/metabase/query_processor/implicit_joins_test.clj+++ b/test/metabase/query_processor/implicit_joins_test.clj@@ -217,7 +217,7 @@:breakout [$orders.product_id->products.category]:aggregation [[:count]]:limit 1})))))- (testing "Should still work if the query is has refs generated by MLv2 that have extra keys"+ (testing "Should still work if the query is has refs generated by Lib that have extra keys"(is (= [["Doohickey" 3976]](mt/formatted-rows[str int]diff --git a/test/metabase/query_processor/middleware/add_remaps_test.clj b/test/metabase/query_processor/middleware/add_remaps_test.cljindex c072e6e6d52..8cef2a584ab 100644--- a/test/metabase/query_processor/middleware/add_remaps_test.clj+++ b/test/metabase/query_processor/middleware/add_remaps_test.clj@@ -488,7 +488,7 @@;;; `partial=`, which ended up asserting nothing of value. However, other tests for this;;; issue, [[metabase.query-processor.remapping-test/remapped-columns-in-joined-source-queries-test]], and a test;;; in `e2e/test/scenarios/joins/joins.cy.spec.js`, are still passing. So I'm not sure what to do with this test. I-;;; updated it to use MLv2, but it's commented out for now.+;;; updated it to use Lib, but it's commented out for now.;;;;;; Note that it mostly passes if you;;; update [[metabase.query-processor.middleware.add-remaps/remap-column-infos]] not to ignore `:field`diff --git a/test/metabase/query_processor/middleware/auto_parse_filter_values_test.clj b/test/metabase/query_processor/middleware/auto_parse_filter_values_test.cljindex f1a1afd8975..3e241be35c5 100644--- a/test/metabase/query_processor/middleware/auto_parse_filter_values_test.clj+++ b/test/metabase/query_processor/middleware/auto_parse_filter_values_test.clj@@ -30,7 +30,7 @@base-type (.getCanonicalName (class expected)))(let [query (-> (lib/query meta/metadata-provider (meta/table-metadata :venues))(lib/filter (lib/= (meta/field-metadata :venues :price)- ;; apparently we have no MLv2 helper for creating `:value` clauses+ ;; apparently we have no Lib helper for creating `:value` clauses[:value{:base-type base-type, :effective-type base-type, :lib/uuid (str (random-uuid))}(str expected)])))]diff --git a/test/metabase/query_processor/middleware/fetch_source_query_test.clj b/test/metabase/query_processor/middleware/fetch_source_query_test.cljindex 0a3c84d8dba..f5b2e41819a 100644--- a/test/metabase/query_processor/middleware/fetch_source_query_test.clj+++ b/test/metabase/query_processor/middleware/fetch_source_query_test.clj@@ -21,8 +21,8 @@(defn resolve-source-cards* [query];; 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)]+ (letfn [(thunk [] (let [mbql5-query (lib.query/query (qp.store/metadata-provider) query)+ resolved (fetch-source-query/resolve-source-cards mbql5-query)](cond-> resolved(not (:lib/type query)) lib.convert/->legacy-MBQL)))](if (qp.store/initialized?)diff --git a/test/metabase/query_processor/pipeline_queries_test.clj b/test/metabase/query_processor/pipeline_queries_test.cljdeleted file mode 100644index 69c3b857d0f..00000000000--- a/test/metabase/query_processor/pipeline_queries_test.clj+++ /dev/null@@ -1,53 +0,0 @@-(ns metabase.query-processor.pipeline-queries-test- (:require- [clojure.test :refer :all]- [metabase.lib.core :as lib]- [metabase.lib.metadata :as lib.metadata]- [metabase.query-processor.test :as qp]- [metabase.test :as mt]- [metabase.util :as u]))--(defn- metadata-provider []- (mt/metadata-provider))--;;; this stuff is mostly so we can get a sense of what using MLv2 in tests will ultimately look like--(defn- query-for-table-id- [table-name]- (let [provider (metadata-provider)- table-metadata (lib.metadata/table provider (mt/id table-name))]- (lib/query provider table-metadata)))--(declare ^:private $price)--(defmacro ^:private mbql5-query- {:style/indent 1}- [table-name & body]- `(let [query# (query-for-table-id ~(keyword table-name))- ~'$price (lib.metadata/field query# (mt/id :venues :price))]- (-> query#- ~@body)))--(defmacro ^:private run-mbql5-query- {:style/indent 1}- [table-name & body]- `(qp/process-query (mbql5-query ~table-name ~@body)))--(deftest ^:parallel pipeline-queries-test- (testing "Ensure that the QP can handle MBQL 5 queries"- (is (= [6]- (mt/first-row- (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 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)- mt/obj->json->obj)]- (testing (format "Query =\n%s" (u/pprint-to-str query))- (is (= [6]- (mt/first-row (qp/process-query query))))))))diff --git a/test/metabase/query_processor/pivot_test.clj b/test/metabase/query_processor/pivot_test.cljindex d0163b13071..8ba08c5ec85 100644--- a/test/metabase/query_processor/pivot_test.clj+++ b/test/metabase/query_processor/pivot_test.clj@@ -632,7 +632,7 @@(deftest ^:parallel mbql-5-query-test(testing "Should be able to run a pivot query for an MBQL 5 query (#39024)"- ;; this is literally the same query as [[pivot-with-order-by-aggregation-test]], just in MLv2, so it should return+ ;; this is literally the same query as [[pivot-with-order-by-aggregation-test]], just in Lib, so it should return;; the same exact results.(let [metadata-provider (mt/metadata-provider)reviews (lib.metadata/table metadata-provider (mt/id :reviews))diff --git a/test/metabase/query_processor/preprocess_test.clj b/test/metabase/query_processor/preprocess_test.cljindex 25a6931eb19..1a7886be388 100644--- a/test/metabase/query_processor/preprocess_test.clj+++ b/test/metabase/query_processor/preprocess_test.clj@@ -551,7 +551,7 @@;;; adapted from [[metabase.query-processor.explicit-joins-test/test-31769]](deftest ^:parallel test-31769- (testing "Make sure queries built with MLv2 that have source Cards with joins work correctly (#31769) (#33083)"+ (testing "Make sure queries built with Lib that have source Cards with joins work correctly (#31769) (#33083)"(let [mp (lib.tu.mocks-31769/mock-metadata-provider meta/metadata-provider meta/id)query (lib.tu.mocks-31769/query mp)](is (=? {:stages [{:source-card 1}diff --git a/test/metabase/query_processor/test_util.clj b/test/metabase/query_processor/test_util.cljindex 8739b6eaaff..7bb94ab1479 100644--- a/test/metabase/query_processor/test_util.clj+++ b/test/metabase/query_processor/test_util.clj@@ -498,7 +498,7 @@(mapv #(metadata-fn % card) metadata)))))(mu/defn metadata-provider-with-cards-for-queries :- ::lib.schema.metadata/metadata-provider- "Create an MLv2 metadata provider (by default, based on the app DB metadata provider) that adds a Card for each query+ "Create an Lib metadata provider (by default, based on the app DB metadata provider) that adds a Card for each queryin `queries`. Cards do not include result metadata. Cards have IDs starting at `1` and increasing sequentially."([queries](metadata-provider-with-cards-for-queriesdiff --git a/test/metabase/transforms/query_test_util.clj b/test/metabase/transforms/query_test_util.cljindex 5e8607d46ec..607cee24acd 100644--- a/test/metabase/transforms/query_test_util.clj+++ b/test/metabase/transforms/query_test_util.clj@@ -27,7 +27,7 @@- :filter-fn - Filter function to use (optional, e.g., lib/=, lib/starts-with)- :filter-values - Values to pass to filter function (optional)- Returns an MLv2 query object."+ Returns an MBQL 5 query object."[& {:keys [source-table source-column filter-fn filter-values]}](let [mp (mt/metadata-provider)table (if (string? source-table)