Skip to content

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

CI: query-processor module should trigger driver tests (#68877)

bryan92a60c8529aa
diff --git a/bb.edn b/bb.edn
index c24929e34ec..deaa880a171 100644
--- a/bb.edn
+++ b/bb.edn
@@ -327,12 +327,13 @@
"Cloud driver + its files changed"
"RUN"
(str "any of " (pr-str driver-triggers) " affected by cloud-driver module changes")]
- ["7" "Cloud driver, no relevant changes" "SKIP" "no relevant changes for cloud driver"]
- ["8"
+ ["7" "Cloud driver + query-processor updated" "RUN" "query-processor module updated"]
+ ["8" "Cloud driver, no relevant changes" "SKIP" "no relevant changes for cloud driver"]
+ ["9"
(str (pr-str driver-triggers) " module deps affected")
"RUN"
(str "any of " (pr-str driver-triggers) " affected by module changes")]
- ["9" "Self-hosted driver, not affected" "SKIP" "driver module not affected"]])))))
+ ["10" "Self-hosted driver, not affected" "SKIP" "driver module not affected"]])))))
:options [[nil "--git-ref REF" "The git ref to compute changed modules against"]
[nil "--is-master-or-release MASTER_OR_RELEASE"]
[nil "--pr-labels PR_LABELS" "Comma delimited labels on the pr"]
diff --git a/mage/src/mage/modules.clj b/mage/src/mage/modules.clj
index e18d79f130c..2854d6671f5 100644
--- a/mage/src/mage/modules.clj
+++ b/mage/src/mage/modules.clj
@@ -346,7 +346,8 @@
[driver
{:keys [is-master-or-release pr-labels skip particular-driver-changed? verbose?]}
driver-deps-affected?
- quarantined-drivers]
+ quarantined-drivers
+ updated]
(cond
;; Priority 1: Global skip (no backend changes)
skip
@@ -386,17 +387,23 @@
{:should-run true
:reason (str "driver files changed (modules/drivers/" (name driver) "/**)")}
- ;; Priority 7: Cloud driver, no relevant changes
+ ;; Priority 7: Cloud driver + query-processor updated → run it
+ (and (contains? cloud-drivers driver)
+ (contains? updated 'query-processor))
+ {:should-run true
+ :reason "query-processor module updated"}
+
+ ;; Priority 8: Cloud driver, no relevant changes → skip
(contains? cloud-drivers driver)
{:should-run false
:reason "no relevant changes for cloud driver"}
- ;; Priority 8: Driver deps affected by shared code changes
+ ;; Priority 9: Driver deps affected by shared code changes
driver-deps-affected?
{:should-run true
:reason "driver module affected by shared code changes"}
- ;; Priority 9: Self-hosted driver, not affected
+ ;; Priority 10: Self-hosted driver, not affected
:else
{:should-run false
:reason "driver module not affected"}))
@@ -433,7 +440,7 @@
;; For module dependency check, combine both conditions
effective-driver-affected? (or driver-affected? important-file-changed?)
decisions (mapv (fn [driver]
- (assoc (driver-decision driver ctx effective-driver-affected? quarantined)
+ (assoc (driver-decision driver ctx effective-driver-affected? quarantined updated)
:driver driver))
all-drivers)
;; Check for quarantined drivers with file changes but no break-quarantine label
diff --git a/mage/test/mage/modules_test.clj b/mage/test/mage/modules_test.clj
index f7178999dec..aaeae12df9a 100644
--- a/mage/test/mage/modules_test.clj
+++ b/mage/test/mage/modules_test.clj
@@ -27,7 +27,8 @@
(let [result (mage.modules/driver-decision :mysql
(make-ctx {})
false ; driver-module-affected?
- #{:mysql})] ; quarantined
+ #{:mysql} ; quarantined
+ #{})] ; updated
(is (false? (:should-run result)))
(is (= "driver is quarantined" (:reason result))))))
@@ -36,7 +37,8 @@
(let [result (mage.modules/driver-decision :mysql
(make-ctx {:pr-labels #{"break-quarantine-mysql"}})
false
- #{:mysql})]
+ #{:mysql}
+ #{})]
(is (true? (:should-run result)))
(is (re-find #"break-quarantine-mysql" (:reason result))))))
@@ -45,7 +47,8 @@
(let [result (mage.modules/driver-decision :mysql
(make-ctx {:is-master-or-release true})
true ; driver-deps-affected?
- #{:mysql})] ; quarantined
+ #{:mysql} ; quarantined
+ #{})] ; updated
(is (false? (:should-run result)))
(is (= "driver is quarantined" (:reason result))))))
@@ -59,7 +62,8 @@
(let [result (mage.modules/driver-decision driver
(make-ctx {:skip true})
true ; even if affected
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (false? (:should-run result))
(str driver " should be skipped"))
(is (= "workflow skip (no backend changes)" (:reason result)))))))
@@ -69,7 +73,8 @@
(let [result (mage.modules/driver-decision :mysql
(make-ctx {:skip true})
false
- #{:mysql})]
+ #{:mysql}
+ #{})]
(is (false? (:should-run result)))
(is (= "workflow skip (no backend changes)" (:reason result))))))
@@ -83,7 +88,8 @@
(let [result (mage.modules/driver-decision driver
(make-ctx {:is-master-or-release false})
false ; driver module not affected
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (true? (:should-run result))
(str driver " should always run"))
(is (= "H2/Postgres always run" (:reason result)))))))
@@ -94,7 +100,8 @@
(let [result (mage.modules/driver-decision driver
(make-ctx {:skip true})
false
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (false? (:should-run result))
(str driver " should be skipped on global skip"))
(is (= "workflow skip (no backend changes)" (:reason result)))))))
@@ -110,13 +117,14 @@
(let [result (mage.modules/driver-decision driver
(make-ctx {:is-master-or-release true})
false ; even if not affected
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (true? (:should-run result))
(str driver " should run on master"))
(is (= "master/release branch" (:reason result)))))))
;;; =============================================================================
-;;; Priority 8: Driver deps affected (self-hosted only)
+;;; Priority 9: Driver deps affected (self-hosted only)
;;; =============================================================================
(deftest driver-deps-affected-runs-self-hosted-drivers
@@ -126,13 +134,14 @@
(let [result (mage.modules/driver-decision driver
(make-ctx {})
true ; driver-deps-affected
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (true? (:should-run result))
(str driver " should run when driver module affected"))
(is (= "driver module affected by shared code changes" (:reason result)))))))
;;; =============================================================================
-;;; Priority 5-7: Cloud driver special rules
+;;; Priority 5-8: Cloud driver special rules
;;; =============================================================================
(deftest cloud-driver-with-label-runs
@@ -141,7 +150,8 @@
(let [result (mage.modules/driver-decision driver
(make-ctx {:pr-labels #{"ci:all-cloud-drivers"}})
false ; not affected
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (true? (:should-run result))
(str driver " should run with label"))
(is (= "ci:all-cloud-drivers label" (:reason result)))))))
@@ -151,23 +161,37 @@
(let [result (mage.modules/driver-decision :athena
(make-ctx {:particular-driver-changed? #{:athena}})
false
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (true? (:should-run result)))
(is (re-find #"driver files changed" (:reason result))))))
+(deftest cloud-driver-with-query-processor-changes-runs
+ (testing "Cloud driver runs when query-processor module is updated"
+ (doseq [driver [:athena :bigquery :databricks :redshift :snowflake]]
+ (let [result (mage.modules/driver-decision driver
+ (make-ctx {})
+ false ; not affected
+ #{} ; quarantined
+ #{'query-processor})] ; updated
+ (is (true? (:should-run result))
+ (str driver " should run when query-processor updated"))
+ (is (= "query-processor module updated" (:reason result)))))))
+
(deftest cloud-driver-without-changes-skips
(testing "Cloud driver skips when no relevant changes"
(doseq [driver [:athena :bigquery :databricks :redshift :snowflake]]
(let [result (mage.modules/driver-decision driver
(make-ctx {})
false ; not affected
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (false? (:should-run result))
(str driver " should skip without changes"))
(is (= "no relevant changes for cloud driver" (:reason result)))))))
;;; =============================================================================
-;;; Priority 9: Self-hosted drivers
+;;; Priority 10: Self-hosted drivers
;;; =============================================================================
(deftest self-hosted-driver-not-affected-skips
@@ -177,7 +201,8 @@
(let [result (mage.modules/driver-decision driver
(make-ctx {})
false ; not affected
- #{})]
+ #{} ; quarantined
+ #{})] ; updated
(is (false? (:should-run result))
(str driver " should skip when not affected"))
(is (= "driver module not affected" (:reason result)))))))
diff --git a/src/metabase/query_processor.clj b/src/metabase/query_processor.clj
index b505b5d7298..fad0c7688a5 100644
--- a/src/metabase/query_processor.clj
+++ b/src/metabase/query_processor.clj
@@ -114,3 +114,4 @@
(-> query
(userland-query info)
(assoc-in [:middleware :add-default-userland-constraints?] true))))
+;; test