Skip to content

Commit

Permalink
Test that changing the type of an int does't break the join (#380)
Browse files Browse the repository at this point in the history
* Made #! portable

* Added missing left-join tests

* Test that changing the int type of a column doesn’t break the join

* Add testing to the refer
  • Loading branch information
otfrom committed Oct 15, 2023
1 parent c81e07d commit 113c160
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/get-data.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

DATA_DIR=test/data/ames-house-prices

Expand Down
23 changes: 22 additions & 1 deletion test/tech/v3/dataset/join_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[tech.v3.datatype.packing :as packing]
[tech.v3.datatype.functional :as dfn]
[tech.v3.datatype.datetime :as dtype-dt]
[clojure.test :refer [deftest is]])
[clojure.test :refer [deftest is testing]])
(:import [java.time LocalDate]))


Expand Down Expand Up @@ -281,8 +281,29 @@
{:name "c" :a 1.0 :b 2.0}])
b (ds/->dataset [{:name "a" :c 1.0}
{:name "b" :c 1.0}])]
(is (= [1.0 1.0 nil]
(vec ((ds-join/left-join :name a b) :c))))
(is (= ["a" "b" nil]
(vec ((ds-join/left-join :name a b) :right.name))))
(is (= [2.0 2.0 2.0]
(vec ((ds-join/left-join :name a b) :b))))
(is (= [1.0 1.0 1.0]
(vec ((ds-join/left-join :name a b) :a))))
(is (= ["a" "b" "c"]
(vec ((ds-join/left-join :name a b) :name))))
(ds-join/left-join :name a b)))

(deftest eraderna-left-join
(testing "Changing the type of int shouldn't break the join"
(let [a (-> (ds/->dataset [{:y 2022}]))
a' (-> a
(ds/column-cast :y :int16))
b (ds/->dataset [{:y 2022 :s "2022"}
{:y 2023 :s "2023"}])]
(is (=
((ds-join/left-join :y a b) :s)
((ds-join/left-join :y a' b) :s))))))


(deftest cross-join
(let [res (ds-join/pd-merge
Expand Down

0 comments on commit 113c160

Please sign in to comment.