     (update-successful-job-execution conn {:id job-execution-id})))
 
 (defn successful-update
-  "On a successful update we need to create a new dataset-version that is an exact copy
-   of the previous one, except with an updated :version and pointing to the new table-name
-   and imported-table-name. We also delete the previous table-name and imported-table-name
-   so we don't accumulate unused datasets on each update."
-  [conn job-execution-id dataset-id table-name imported-table-name dataset-version]
+  "On a successful update we need to create a new dataset-version that
+  is similar to the previous one, except with an updated :version and
+  pointing to the new table-name, imported-table-name and columns. We
+  also delete the previous table-name and imported-table-name so we
+  don't accumulate unused datasets on each update."
+  [conn job-execution-id dataset-id table-name imported-table-name dataset-version new-columns]
   (insert-dataset-version conn {:id (str (squuid))
                                 :dataset-id dataset-id
                                 :job-execution-id job-execution-id
                                 :table-name table-name
                                 :imported-table-name imported-table-name
                                 :version (inc (:version dataset-version))
-                                :columns (vec (:columns dataset-version))
+                                :columns new-columns
                                 :transformations (vec (:transformations dataset-version))})
   (drop-table (:imported-table-name dataset-version))
   (drop-table (:table-name dataset-version))

                                   :to-table imported-table-name}
                                  {}
                                  {:transaction? false})
                (apply-transformation-log conn table-name imported-columns transformations)
                (successful-update conn
                                   job-execution-id
                                   dataset-id
                                   table-name
                                   imported-table-name
                                   dataset-version))))))
    (catch clojure.lang.ExceptionInfo e
      (failed-update conn job-execution-id (.getMessage e))
      (throw e))

      columns)))

(defn compatible-columns? [imported-columns columns]
  (let [imported-columns (map (fn [column]
                                {:id (keyword (get column "columnName"))
                                 :type (keyword (get column "type"))
                                 :title (get column "title")})
                              imported-columns)]
    (set/subset? (set imported-columns)
                 (set columns))))

(defn do-update [conn config dataset-id data-source-id job-execution-id data-source-spec]
  (try
