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
Fix Metabot failing to read metrics that have a breakout (#82951)
Andrei Simionescu2b50816eef11
diff --git a/src/metabase/metabot/tools/entity_details.clj b/src/metabase/metabot/tools/entity_details.cljindex 0abd384a2b2..b25f3fa44e4 100644--- a/src/metabase/metabot/tools/entity_details.clj+++ b/src/metabase/metabot/tools/entity_details.clj@@ -387,9 +387,7 @@(some->> (:dataset-query metric-card) (lib/query metadata-provider))(set (keep :id base-filterable-cols))))visible-cols (when query-needed?- (->> (lib/visible-columns base-query)- permission-filter-columns- (map #(metabot.tools.u/add-table-reference base-query %))))+ (permission-filter-columns (lib/visible-columns base-query)))default-temporal-breakout (when (and query-needed? with-default-temporal-breakout?)(->> breakouts(map #(lib/find-matching-column % visible-cols))diff --git a/test/metabase/metabot/tools/entity_details_test.clj b/test/metabase/metabot/tools/entity_details_test.cljindex 9a76996acc3..e3d52ab934c 100644--- a/test/metabase/metabot/tools/entity_details_test.clj+++ b/test/metabase/metabot/tools/entity_details_test.clj@@ -909,6 +909,17 @@(mt/with-current-user (mt/user->id :crowberto)(is (nil? (:join-required-dimensions (metric-details-for unjoined-metric-query)))))))+(deftest metric-details-default-time-dimension-test+ (testing "metric-details finds the time dimension a metric breaks out by when its table has FK-reachable columns"+ (mt/with-current-user (mt/user->id :crowberto)+ (is (= (mt/id :orders :created_at)+ (:default_time_dimension_field_id+ (metric-details-for+ (fn [mp]+ (lib/breakout (unjoined-metric-query mp)+ (lib/with-temporal-bucket (lib.metadata/field mp (mt/id :orders :created_at))+ :month))))))))))+(deftest metric-details-omits-join-required-dimensions-when-export-fails-test(testing (str "fail closed: when the portable join clause cannot be exported, the entry is DROPPED ""rather than surfaced with a nil join - instructing the LLM to paste `null` into "