       (drake/run-workflow drakefile :targetv ["=..."]))
     
     (with-db (get-db dataset)
-      (doseq [[table definition] tables]
-        (log/info "Loading table" (name table) "for dataset" dataset)
-        (load-table table definition dir))
       (doseq [slice slice-load-order]
         (log/info "Loading slice" (name slice) "for dataset" dataset)
-        (load-slice dataset slice (slices slice)))
+        (load-slice dataset slice (slices slice) tables dir))
       (doseq [[concept definition] concepts]
-        (log/info "Updating slices with concept" concept)        
-        (load-concept concept definition slices))
+        (log/info "Loading concept" concept)        
+        (load-concept dataset concept definition slices tables dir))
       (doseq [[slice definition] slices]
         (log/info "Indexing slice" slice)
         (set-indexes slice (:dimensions definition))))))

        chunks (->> query-result
                    :data
                    (partition-all *chunk-size*))]
    (log/info "Loading derived slice" slice)
    (doseq [chunk chunks]
      (coll/insert-batch to-collection chunk))))

(defn- load-slice
  [dataset slice slicedef]
  (let [dimensions (:dimensions slicedef)
        type (keyword (:type slicedef))]
    (log/info "Dropping slice" slice)
    (coll/drop slice)
    (case type
      :table (load-table-slice dataset slice slicedef)
      :derived (load-derived-slice dataset slice slicedef)
      (log/error "Cannot load slice" slice "with type" type))))

(defn- load-concept
  "Go through each slice and replace any dimensions that match a
concept where the concept is backed by a table with the relevant row
from that table."
  [concept definition slices]
  "whoa")

(defn load-dataset
  "Given the name of a dataset, load that dataset from disk into the

      (doseq [chunk chunks]
        (coll/insert-batch collection chunk)))))

(defn- load-collection
  [collection tabledef dir]
  (coll/drop collection)  
  (let [sources (:sources tabledef)
        columns (:columns tabledef)
        agent-error-handler (fn [agent exception]
                              (log/error "Error in table loading agent"
                                         (.getMessage exception)))
        agents (map (fn [source]
                      (agent source
                             :error-mode :continue
                             :error-handler agent-error-handler))
                    sources)]
    (doseq [agent agents]
      (send-off agent (fn [file]
                        (load-csv-file collection (str dir "/" file) columns))))
    (apply await agents)))

(defn- load-table-slice
  [dataset slice slicedef tables dir]
  (let [table (:table slicedef)
        tabledef ((keyword table) tables)
        collection (name slice)]
    (log/info "Loading table-backed slice" slice)
    (load-collection collection tabledef dir)))

(defn- load-derived-slice
  [dataset slice slicedef]
