diff --git a/src/metabase/query_processor/annotate.clj b/src/metabase/query_processor/annotate.clj index d06922c2ab0e50f43e9e1495e95b31707ad39749..1f556bd0061eee3a8cfb47b38c465b3a4c0fca6b 100644 --- a/src/metabase/query_processor/annotate.clj +++ b/src/metabase/query_processor/annotate.clj @@ -166,7 +166,7 @@ since at this time we can't resolve those normally (#1786) fall back to using the metadata for the first column (e.g., `count`). This is definitely a HACK, but in most cases this should be correct (or at least better than the generic info) for the important things like type information." [fields k] - (when-let [[_ field-name-without-suffix] (re-matches #"(.*)_\d+$" (name k))] + (when-let [[_ field-name-without-suffix] (re-matches #"^(.*)_\d+$" (name k))] (some (fn [{field-name :field-name, :as field}] (when (= (name field-name) field-name-without-suffix) (merge (generic-info-for-missing-key k) diff --git a/test/metabase/query_processor_test/aggregation_test.clj b/test/metabase/query_processor_test/aggregation_test.clj index 7e4314eec408f3e88f3e95967fb808d91de1e69c..1f44569abab6eb02f4edbba4657a097f3f61aa63 100644 --- a/test/metabase/query_processor_test/aggregation_test.clj +++ b/test/metabase/query_processor_test/aggregation_test.clj @@ -149,7 +149,8 @@ (ql/aggregation (ql/avg $price) (ql/count) (ql/sum $price)))))) ;; make sure that multiple aggregations of the same type have the correct metadata (#4003) -(expect-with-non-timeseries-dbs +;; (TODO - this isn't tested against Mongo because the Mongo driver currently combines duplicate aggregations of the same time into a single type) +(datasets/expct-with-engines (disj non-timeseries-engines :mongo) [(aggregate-col :count) (assoc (aggregate-col :count) :display_name "count_2"