Schemas for things related to joins. | (ns metabase.lib.schema.join (:require [metabase.lib.schema.common :as common] [metabase.lib.schema.expression :as expression] [metabase.util.i18n :as i18n] [metabase.util.malli.registry :as mr])) |
The Fields to include in the results if a top-level
Driver implementations: you can ignore this clause. Relevant fields will be added to top-level | (mr/def ::fields [:multi {:dispatch (some-fn keyword? string?)} [true [:enum {:decode/normalize common/normalize-keyword} :all :none]] ;; TODO -- `:fields` is supposed to be distinct (ignoring UUID), e.g. you can't have `[:field {} 1]` in there ;; twice. (#32489) [false [:sequential {:min 1} [:ref :mbql.clause/field]]]]) |
The name used to alias the joined table or query. This is usually generated automatically and generally looks
like Driver implementations: This is guaranteed to be present after pre-processing. | (mr/def ::alias [:schema {:gen/fmap #(str % "-" (random-uuid))} ::common/non-blank-string]) |
(mr/def ::conditions [:sequential {:min 1} [:ref ::expression/boolean]]) | |
valid values for the optional When | (mr/def ::strategy [:enum {:decode/normalize common/normalize-keyword} :left-join :right-join :inner-join :full-join]) |
(mr/def ::join [:map {:decode/normalize common/normalize-map} [:lib/type [:= {:decode/normalize common/normalize-keyword} :mbql/join]] [:lib/options ::common/options] [:stages [:ref :metabase.lib.schema/stages]] [:conditions ::conditions] [:alias ::alias] [:ident {:optional true} ::common/non-blank-string] [:fields {:optional true} ::fields] [:strategy {:optional true} ::strategy]]) | |
(mr/def ::joins [:and [:sequential {:min 1} [:ref ::join]] [:fn {:error/fn (fn [& _] (i18n/tru "Join aliases must be unique at a given stage of a query"))} (fn ensure-unique-join-aliases [joins] (if-let [aliases (not-empty (filter some? (map :alias joins)))] (apply distinct? aliases) true))]]) | |
(mr/def ::strategy.option [:map [:lib/type [:= :option/join.strategy]] [:strategy [:ref ::strategy]] [:default {:optional true} :boolean]]) | |