                                                                         :dataset-id dataset-id})
      (future
        (try
-         (let [{:keys [table-name imported-table-name
-                       importer-columns imported-dataset-columns
-                       latest-dataset-version success?]}  (import-data-to-table tenant-conn
-                                                                                import-config
-                                                                                dataset-id
-                                                                                job-execution-id
-                                                                                data-source-spec)]
-           (when success?
-             (let [{:keys [columns transformations]} (engine/apply-dataset-transformations-on-table tenant-conn
-                                                                                                    caddisfly
-                                                                                                    dataset-id
-                                                                                                    (:transformations latest-dataset-version)
-                                                                                                    table-name
-                                                                                                    importer-columns
-                                                                                                    imported-dataset-columns)]
-               (successful-update tenant-conn job-execution-id dataset-id table-name imported-table-name latest-dataset-version columns transformations))))
+         (if (get (env/all tenant-conn) "data-groups")
+           (let [{:keys [group-table-names
+                         importer-columns imported-dataset-columns
+                         latest-dataset-version success?] :as foo} (import-data-to-table-2 tenant-conn
+                                                                                   import-config
+                                                                                   dataset-id
+                                                                                   job-execution-id
+                                                                                   data-source-spec)]
+             (throw  (ex-info "foo" foo))
+             #_(when success?
+               (let [{:keys [columns transformations]}
+                     (engine/apply-dataset-transformations-on-table-2 tenant-conn
+                                                                      caddisfly
+                                                                      dataset-id
+                                                                      (:transformations latest-dataset-version)
+                                                                      table-name
+                                                                      importer-columns
+                                                                      imported-dataset-columns)]
+                 (successful-update-2 tenant-conn job-execution-id dataset-id table-name imported-table-name latest-dataset-version columns transformations))))
+           (let [{:keys [table-name imported-table-name
+                         importer-columns imported-dataset-columns
+                         latest-dataset-version success?]}  (import-data-to-table tenant-conn
+                                                                                  import-config
+                                                                                  dataset-id
+                                                                                  job-execution-id
+                                                                                  data-source-spec)]
+             (when success?
+               (let [{:keys [columns transformations]} (engine/apply-dataset-transformations-on-table tenant-conn
+                                                                                                      caddisfly
+                                                                                                      dataset-id
+                                                                                                      (:transformations latest-dataset-version)
+                                                                                                      table-name
+                                                                                                      importer-columns
+                                                                                                      imported-dataset-columns)]
+                 (successful-update tenant-conn job-execution-id dataset-id table-name imported-table-name latest-dataset-version columns transformations)))))
          (catch Exception e
            (failed-update tenant-conn job-execution-id (.getMessage e))
            (p/track error-tracker e)

            [clojure.data :as d]
            [akvo.lumen.db.dataset-version :as db.dataset-version]
            [clojure.tools.logging :as log]
            [akvo.lumen.db.transformation :as db.transformation]
            [akvo.lumen.db.job-execution :as db.job-execution]
            [clojure.walk :as walk]))

            [akvo.lumen.lib :as lib]
            [akvo.lumen.lib.env :as env]
            [akvo.lumen.lib.transformation.engine :as engine]
            [akvo.lumen.lib.import.data-groups :as import.data-groups]
            [akvo.lumen.util :as util]
            [clojure.java.jdbc :as jdbc]
            [clojure.set :as set]
