-
- Downloads
source-field populated in aggregates with foreign refs (#38624)
* source-field populated in aggregates with foreign refs When aggregates are populated that reference other tables, either a `:source-field` must be provided in the field metadata or a `:join-alias` needs to be provided. The former is preferred. Prior to this PR, the first situation in the below simplified case could happen: ```clojure ;;Simplified case ;; busted (qp/process-query {:database 1, ;; 59 is "PRODUCTS" -> "PRICE" which is not in the "REVIEWS" table :query {:aggregation [["sum" ["field" 59 {:base-type "type/Float"}]]] ;; "REVIEWS" :source-table 8}, :type "query"}) ; Works (qp/process-query {:database 1, ;; The `:source-field` metadata fixes the above query :query {:aggregation [["sum" ["field" 59 {:base-type "type/Float" ;; "REVIEWS" -> "PRODUCT_ID" :source-field 71}]]] :source-table 8}, :type "query"}) ``` This PR updates `metabase.automagic-dashboards.interestin/ground-metric` to use the `->reference` function for fields when building the `decoder` for transforming field names to references, which properly adds sources for external fields. Fixes #38618 * Updating `grounded-metrics-test` to reflect updated field referencing.
Showing
- src/metabase/automagic_dashboards/interesting.clj 83 additions, 84 deletionssrc/metabase/automagic_dashboards/interesting.clj
- test/metabase/automagic_dashboards/core_test.clj 16 additions, 0 deletionstest/metabase/automagic_dashboards/core_test.clj
- test/metabase/automagic_dashboards/interesting_test.clj 11 additions, 11 deletionstest/metabase/automagic_dashboards/interesting_test.clj
Loading
Please register or sign in to comment