Skip to content
Snippets Groups Projects
Unverified Commit d25a515c authored by Cal Herries's avatar Cal Herries Committed by GitHub
Browse files

Simplify two-case-functions-test (#26485)

parent f4341499
No related branches found
No related tags found
No related merge requests found
(ns metabase.query-processor-test.case-test
(:require [clojure.test :refer :all]
[metabase.driver :as driver]
[metabase.models :refer [Metric Segment]]
[metabase.test :as mt]))
......@@ -88,33 +87,12 @@
(testing "We should support expressions with two case statements (#15107)"
(mt/test-drivers (mt/normal-drivers-with-feature :expressions)
(mt/dataset sample-dataset
(is (= [[1
"1018947080336"
"Rustic Paper Wallet"
"Gizmo"
"Swaniawski, Casper and Hilll"
29.46
4.6
(if (= driver/*driver* :sqlite)
"2017-07-19T19:44:56Z"
"2017-07-19T19:44:56.582Z")
1]
[2
"7663515285824"
"Small Marble Shoes"
"Doohickey"
"Balistreri-Ankunding"
70.08
0.0
(if (= driver/*driver* :sqlite)
"2019-04-11T08:49:35Z"
"2019-04-11T08:49:35.932Z")
0]]
(mt/formatted-rows [int str str str str 2.0 2.0 str int]
(mt/run-mbql-query products
{:expressions
{:TwoCases [:+
[:case [[[:= $category "Widget"] 1]] {:default 0}]
[:case [[[:> $rating 4] 1]] {:default 0}]]}
:limit 2
:order-by [[:asc $id]]}))))))))
(is (= [[1] [0]]
(mt/formatted-rows [int]
(mt/run-mbql-query products
{:fields [[:expression "two-cases"]]
:expressions {"two-cases" [:+
[:case [[[:= $category "Widget"] 1]] {:default 0}]
[:case [[[:> $rating 4] 1]] {:default 0}]]}
:limit 2
:order-by [[:asc $id]]}))))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment