Skip to content
Snippets Groups Projects
Unverified Commit 81edcd40 authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Tests for filtering by numeric columns in Druid (#10935) [ci druid] (#12561)

parent 718c2fdf
No related branches found
No related tags found
No related merge requests found
......@@ -582,3 +582,54 @@
:breakout [$venue_category_name $user_name]
:order-by [[:desc [:aggregation 0]] [:asc $checkins.venue_category_name]]
:limit 5}))))))
(deftest filter-by-numeric-column-test
(mt/test-driver :druid
(testing "Make sure we can filter by numeric columns (#10935)"
(tqpt/with-flattened-dbdef
(letfn [(compiled [query]
(-> (qp/query->native query) :query (select-keys [:filter :queryType])))]
(testing "scan query"
(let [query (mt/mbql-query checkins
{:order-by [[:desc $id]]
:fields [$id $venue_price $venue_name]
:filter [:= $venue_price 1]
:limit 5})]
(is (= {:filter {:type :selector, :dimension "venue_price", :value 1}
:queryType :scan}
(compiled query)))
(is (= ["931" "1" "Kinaree Thai Bistro"]
(mt/first-row (qp/process-query query))))))
(testing "topN query"
(let [query (mt/mbql-query checkins
{:aggregation [[:count]]
:breakout [$venue_price]
:filter [:= $venue_price 1]})]
(is (= {:filter {:type :selector, :dimension "venue_price", :value 1}
:queryType :topN}
(compiled query)))
(is (= ["1" 221]
(mt/first-row (qp/process-query query))))))
(testing "groupBy query"
(let [query (mt/mbql-query checkins
{:aggregation [[:aggregation-options [:distinct $checkins.venue_name] {:name "__count_0"}]]
:breakout [$venue_category_name $user_name]
:order-by [[:desc [:aggregation 0]] [:asc $checkins.venue_category_name]]
:filter [:= $venue_price 1]})]
(is (= {:filter {:type :selector, :dimension "venue_price", :value 1}
:queryType :groupBy}
(compiled query)))
(is (= ["Mexican" "Conchúr Tihomir" 4]
(mt/first-row (qp/process-query query))))))
(testing "timeseries query"
(let [query (mt/mbql-query checkins
{:aggregation [[:count]]
:filter [:= $venue_price 1]})]
(is (= {:queryType :timeseries
:filter {:type :selector, :dimension "venue_price", :value 1}}
(compiled query)))
(is (= [221]
(mt/first-row (qp/process-query query)))))))))))
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