 (deftest ^:functional combine-transformation-test
   (let [dataset-id (import-file *tenant-conn* *error-tracker* {:has-column-headers? true
                                                                :file "name.csv"})
-        apply-transformation (partial transformation/apply {:tenant-conn *tenant-conn*} dataset-id)]
-    (let [[tag _] (apply-transformation {:type :transformation
-                                         :transformation
-                                         (gen-transformation :core/combine
-                                                             {:akvo.lumen.specs.transformation.combine/columnNames ["c1" "c2"]                                                                          :akvo.lumen.specs.transformation.engine/onError "fail"
-                                                              :akvo.lumen.specs.transformation.combine/newColumnTitle "full name"
-                                                              :akvo.lumen.specs.transformation.combine/separator " "})})]
-      (is (= ::lib/ok tag))
-      (let [table-name (:table-name
-                        (latest-dataset-version-by-dataset-id *tenant-conn*
-                                                              {:dataset-id dataset-id}))]
-        (is (= "bob hope"
-               (:d1 (get-val-from-table *tenant-conn*
-                                        {:rnum 1
-                                         :column-name "d1"
-                                         :table-name table-name}))))))
+        apply-transformation (partial transformation/apply {:tenant-conn *tenant-conn*} dataset-id)
+        [tag _] (apply-transformation {:type :transformation
+                                       :transformation (gen-transformation :core/combine
+                                                                           {::transformation.combine.s/columnNames ["c1" "c2"]
+                                                                            ::transformation.engine.s/onError "fail"
+                                                                            ::transformation.combine.s/newColumnTitle "full name"
+                                                                            ::transformation.combine.s/separator " "})})]
+    (is (= ::lib/ok tag))
+    (let [table-name (:table-name
+                      (latest-dataset-version-by-dataset-id *tenant-conn*
+                                                            {:dataset-id dataset-id}))]
+      (is (= "bob hope"
+             (:d1 (get-val-from-table *tenant-conn*
+                                      {:rnum 1
+                                       :column-name "d1"
+                                       :table-name table-name})))))
 
     ;;https://github.com/akvo/akvo-lumen/issues/1517
     (testing "Combining columns where one of the columns has empty values"
       (let [[tag _] (apply-transformation {:type :transformation
                                            :transformation
                                          (gen-transformation :core/combine
-                                                             {:akvo.lumen.specs.transformation.combine/columnNames ["c2" "c3"]                                                                          :akvo.lumen.specs.transformation.engine/onError "fail"
+                                                             {:akvo.lumen.specs.transformation.combine/columnNames ["c2" "c3"]                                                                          ::transformation.engine.s/onError "fail"
                                                               :akvo.lumen.specs.transformation.combine/newColumnTitle "issue1517"
                                                               :akvo.lumen.specs.transformation.combine/separator " "})})]
         (is (= ::lib/ok tag))

      (apply-transformation {:type :transformation
                             :transformation
                             (gen-transformation :core/derive
                                                 {:akvo.lumen.specs.transformation.derive/newColumnTitle "Derived 4"
                                                  :akvo.lumen.specs.transformation.derive/code "row['foo'].toUpperCase()"
                                                  :akvo.lumen.specs.transformation.derive/newColumnType "text"
                                                  :akvo.lumen.specs.transformation.engine/onError "leave-empty"})})
      (is (= ["A" "B" nil] (map :d2 (latest-data dataset-id))))

      (apply-transformation {:type :transformation
                             :transformation
                             (gen-transformation :core/derive
                                                 {:akvo.lumen.specs.transformation.derive/newColumnTitle "Derived 5"
                                                  :akvo.lumen.specs.transformation.derive/code "row['Derived 4'].toLowerCase()"
                                                  :akvo.lumen.specs.transformation.derive/newColumnType "text"
                                                  :akvo.lumen.specs.transformation.engine/onError "leave-empty"})})
      (is (= ["a" "b" nil] (map :d3 (latest-data dataset-id)))))

    (testing "Date transform"
      (let [[tag _] (apply-transformation {:type :transformation
                                           :transformation
                                           (gen-transformation :core/derive
                                                               {:akvo.lumen.specs.transformation.derive/newColumnTitle "Derived 5"
                                                                :akvo.lumen.specs.transformation.derive/code "new Date()"
                                                                :akvo.lumen.specs.transformation.derive/newColumnType "date"
                                                                :akvo.lumen.specs.transformation.engine/onError "fail"})})]
        (is (= tag ::lib/ok))
        (is (every? number? (map :d4 (latest-data dataset-id))))))


        (is (= years-slash (map (comp tcc/from-long :c3) table-data)))
        (is (= years-hiphen (map (comp tcc/from-long :c4) table-data)))))))

(deftest ^:functional derived-column-test
  (let [change-datatype-transformation (fn [column-name]
                                         {:type :transformation
                                          :transformation
                                          (-> (gen-transformation
                                               :core/change-datatype {::db.dataset-version.column.s/columnName "column-name"
                                                                      ::transformation.change-datatype.s/newType "number"
                                                                      ::transformation.engine.s/onError "default-value"})
                                              (assoc-in ["args" "defaultValue"] nil))})
        dataset-id (import-file *tenant-conn* *error-tracker* {:has-column-headers? true
                                                               :file "derived-column.csv"})
        apply-transformation (partial transformation/apply {:tenant-conn *tenant-conn*} dataset-id)]
    (do (apply-transformation (change-datatype-transformation "c2"))
