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
Allow arbitrary expressions inside `:is-null` and `:not-null` in MBQL 4 schema (#67326)
Cam Saul0004f3efc6bd
diff --git a/src/metabase/legacy_mbql/schema.cljc b/src/metabase/legacy_mbql/schema.cljcindex baf022dbbea..d48d9587552 100644--- a/src/metabase/legacy_mbql/schema.cljc+++ b/src/metabase/legacy_mbql/schema.cljc@@ -1053,8 +1053,8 @@lon-max [:ref ::OrderComparable]);; SUGAR CLAUSES: These are rewritten as `[:= <field> nil]` and `[:not= <field> nil]` respectively-(defclause is-null, field [:ref ::FieldOrExpressionRef])-(defclause not-null, field [:ref ::FieldOrExpressionRef])+(defclause is-null, field [:ref ::FieldOrExpressionDef])+(defclause not-null, field [:ref ::FieldOrExpressionDef])(mr/def ::Emptyable"Schema for a valid is-empty or not-empty argument."diff --git a/test/metabase/legacy_mbql/schema_test.cljc b/test/metabase/legacy_mbql/schema_test.cljcindex e903c5c6947..780e15d5aeb 100644--- a/test/metabase/legacy_mbql/schema_test.cljc+++ b/test/metabase/legacy_mbql/schema_test.cljc@@ -630,3 +630,20 @@100]]]normalized))(is (mr/validate ::mbql.s/Aggregations normalized))))++(deftest ^:parallel is-null-not-null-arbitrary-expressions-test+ (testing "is-null and not-null should allow arbitrary expressions"+ (doseq [clause [:is-null+ :not-null]]+ (let [schema (keyword "metabase.legacy-mbql.schema" (name clause))+ expr [(name clause)+ ["="+ ["field" 620 {"base-type" "type/Text"}]+ false]]+ normalized (lib/normalize schema expr)]+ (is (= [clause+ [:=+ [:field 620 {:base-type :type/Text}]+ false]]+ normalized))+ (is (mr/validate schema normalized))))))