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
Use the underlying nested field name (#81640)
metamben8dbfef0fe60d
diff --git a/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.clj b/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.cljindex d76a638b3c3..b66feaea384 100644--- a/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.clj+++ b/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.clj@@ -2286,14 +2286,18 @@ function(bin) {;;; values added by add-alias-info.(defn- HACK-update-aliases-in-field-refs[query]- (letfn [(prepend-nfc-path [{nfc-path driver-api/qp.add.nfc-path,+ (letfn [(raw-mongo-path [id-or-name]+ (when (pos-int? id-or-name)+ (field->name query (driver-api/field query id-or-name))))+ (prepend-nfc-path [raw-path+ {nfc-path driver-api/qp.add.nfc-path,source-alias driver-api/qp.add.source-aliasdesired-alias driver-api/qp.add.desired-alias:as opts}](when (seq nfc-path)(let [nfc-path-str (str/join \. nfc-path)](-> opts- (assoc driver-api/qp.add.source-alias (str nfc-path-str \. source-alias)+ (assoc driver-api/qp.add.source-alias (or raw-path (str nfc-path-str \. source-alias))driver-api/qp.add.desired-alias (str nfc-path-str \. desired-alias))(dissoc driver-api/qp.add.nfc-path)))))(update-name [{field-name :name, source-alias driver-api/qp.add.source-alias, :as opts}]@@ -2309,20 +2313,20 @@ function(bin) {source-table(not= join-alias source-table))(assoc opts :join-alias source-table)))- (update-opts [opts]+ (update-opts [raw-path opts](reduce(fn[opts f](or (f opts)opts))opts- [prepend-nfc-path+ [(partial prepend-nfc-path raw-path)update-join-aliasupdate-nameremove-bad-join-aliasupdate-join-alias]))(update-field-ref [[_tag {source-alias driver-api/qp.add.source-alias, :as _opts} id-or-name, :as field-ref]]- (let [field-ref' (lib/update-options field-ref update-opts)]+ (let [field-ref' (lib/update-options field-ref (partial update-opts (raw-mongo-path id-or-name)))](cond-> field-ref'(and (string? id-or-name)source-alias)diff --git a/modules/drivers/mongo/test/metabase/driver/mongo/query_processor_test.clj b/modules/drivers/mongo/test/metabase/driver/mongo/query_processor_test.cljindex de567c08ff8..3c15fa8f44f 100644--- a/modules/drivers/mongo/test/metabase/driver/mongo/query_processor_test.clj+++ b/modules/drivers/mongo/test/metabase/driver/mongo/query_processor_test.clj@@ -279,7 +279,25 @@compiled (mongo.qp/mbql->native query)let-lhs (-> compiled (get-in [:query 0 "$lookup" :let]) keys first)](is (and (not (str/includes? let-lhs "."))- (str/includes? let-lhs "source_categories"))))))))))+ (str/includes? let-lhs "source_categories")))))+ (testing "Nested fields projected from a joined collection return their real values (#81546)"+ (let [query (lib/query+ (mt/metadata-provider)+ (mt/mbql-query tips+ {:fields [$_id+ $tips.venue.categories+ &Tips.$tips.venue.categories]+ :joins [{:alias "Tips"+ :source-table $$tips+ :condition [:= $_id &Tips.$_id]+ :fields :none}]+ :order-by [[:asc $_id]]+ :limit 3}))+ rows (mt/rows (qp/process-query query))]+ (is (= [[1 ["Gluten-Free" "Café"] ["Gluten-Free" "Café"]]+ [2 ["Homestyle" "Eatery"] ["Homestyle" "Eatery"]]+ [3 ["Cage-Free" "Coffee House"] ["Cage-Free" "Coffee House"]]]+ rows)))))))))(deftest ^:parallel multiple-distinct-count-test(mt/test-driver :mongo