Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Ghy-3258/table tag dependencies missing in incremental transforms (#71316)

Ben Grabow9ec99afb69f1
diff --git a/enterprise/backend/src/metabase_enterprise/dependencies/native_validation.clj b/enterprise/backend/src/metabase_enterprise/dependencies/native_validation.clj
index 625b94fff1f..d440a2d1b1d 100644
--- a/enterprise/backend/src/metabase_enterprise/dependencies/native_validation.clj
+++ b/enterprise/backend/src/metabase_enterprise/dependencies/native_validation.clj
@@ -278,5 +278,6 @@
(keep #(case (:type %)
:snippet {:snippet (:snippet-id %)}
:card {:card (:card-id %)}
+ :table {:table (:table-id %)}
nil))
(lib/all-template-tags query))))
diff --git a/enterprise/backend/test/metabase_enterprise/dependencies/calculation_test.clj b/enterprise/backend/test/metabase_enterprise/dependencies/calculation_test.clj
index a2b8f3fa31b..8435aba1e23 100644
--- a/enterprise/backend/test/metabase_enterprise/dependencies/calculation_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/dependencies/calculation_test.clj
@@ -209,6 +209,23 @@
(is (= {:table #{products-id orders-id}}
(calculation/upstream-deps:transform transform)))))))
+(deftest ^:parallel upstream-deps-native-transform-with-table-tag-test
+ (testing "GHY-3258: native transform with a table template tag should include the table in dependencies"
+ (mt/with-premium-features #{:transforms-basic}
+ (let [mp (mt/metadata-provider)
+ products-id (mt/id :products)
+ query (-> (lib/native-query mp "invalid query {{products_table}}")
+ (lib/with-template-tags {"products_table" {:type :table
+ :table-id products-id
+ :name "products_table"
+ :display-name "Products Table"}}))]
+ (mt/with-temp [:model/Transform transform {:name "Table Tag Transform"
+ :source {:type :query
+ :query query}
+ :target {:schema "PUBLIC"
+ :name "test_output"}}]
+ (is (=? {:table #(contains? % products-id)} (calculation/upstream-deps:transform transform))))))))
+
(deftest ^:parallel upstream-deps-card-native-with-parameter-source-test
(let [mp (mt/metadata-provider)
products-id (mt/id :products)