Skip to content

Commit

Permalink
Add tests for join functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pcbldi committed Sep 16, 2024
1 parent d42c600 commit a32c8af
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/tablecloth/api/join_concat_ds_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,32 @@
(api/dataset [{:k "baz"}])
[:k])
(api/rows :as-maps)) => [{:k "baz", :v "\"baz\""} {:k "baz", :v "\"baz\""}])

(fact "right join with automatic column selector"
(-> (api/right-join (api/dataset [{:i "foo" :y 2022}])
(api/dataset [{:i "foo" :y 2022 :s "2022"}
{:i "foo" :y 2023 :s "2023"}]))
(api/rows :as-maps)) => [{:i "foo", :y 2022, :right.i "foo", :right.y 2022, :s "2022"}
{:i nil, :y nil, :right.i "foo", :right.y 2023, :s "2023"}])

(fact "inner join with automatic column selector"
(-> (api/inner-join (api/dataset [{:i "foo" :y 2022}])
(api/dataset [{:i "foo" :y 2022 :s "2022"}
{:i "foo" :y 2023 :s "2023"}]))
(api/rows :as-maps)) => [{:i "foo", :y 2022, :right.i "foo", :right.y 2022, :s "2022"}])

(fact "full join with automatic column selector"
(-> (api/full-join (api/dataset [{:i "foo" :y 2022}
{:i "bar" :y 2021 }])
(api/dataset [{:i "foo" :y 2022 :s "2022"}
{:i "foo" :y 2023 :s "2023"}]))
(api/rows :as-maps)) => [{:i "foo", :y 2022, :right.i "foo", :right.y 2022, :s "2022"}
{:i "bar", :y 2021, :right.i nil, :right.y nil, :s nil}
{:i nil, :y nil, :right.i "foo", :right.y 2023, :s "2023"}])

(fact "anti join with automatic column selector"
(-> (api/anti-join (api/dataset [{:i "foo" :y 2022}
{:i "bar" :y 2021 }])
(api/dataset [{:i "foo" :y 2022 :s "2022"}
{:i "foo" :y 2023 :s "2023"}]))
(api/rows :as-maps)) => [{:i "bar", :y 2021}])

0 comments on commit a32c8af

Please sign in to comment.