            (cond-> mode (.setMode mode))
            (cond-> nested-fields (.setFields (clj->TableFieldSchema nested-fields transform-keys))))))
 
-(defn ->schema
-  ^TableSchema
+(defn ^TableSchema ->schema
   ([defs transform-keys]
    (if (instance? TableSchema defs)
      defs
      (let [fields (clj->TableFieldSchema defs transform-keys)]
        (-> (TableSchema.) (.setFields fields)))))
-  ([defs] (->schema defs (fn [k] (name k)))))
+  ([defs] (->schema defs name)))
 
 (defn get-bq-table-schema
   "Beware, uses bq util to get the schema!"
   [table-spec]
   (let [{:keys [exit out] :as return} (sh "bq" "--format=json" "show" (name table-spec))]
-    (if (= 0 exit)
+    (if (zero? exit)
       (-> (json/decode out true) (:schema) (:fields))
       (throw (ex-info (str "Could not get bq table schema for table " table-spec)
                       {:table table-spec

                            (fn [transform retrypolicy] (.withFailedInsertRetryPolicy transform retrypolicy)))}}))

(defn custom-output-fn [cust-fn]
  (proxy [SerializableFunction] []
    (apply [elt]
      (safe-exec
       (let [^String out (cust-fn elt)]
         (TableDestination. out nil))))))

(defn format-fn
  []
  (proxy [SerializableFunction] []
    (apply [elt] (safe-exec (clj-nested->table-row elt)))))

(defn write-bq-table-raw
  ([to options ^PCollection pcoll]
   (let [opts (assoc options :label :write-bq-table-raw)]
     (apply-transform pcoll (-> (BigQueryIO/write)
                                (.to to)
                                (.withFormatFunction (format-fn)))
                      write-bq-table-schema opts)))
  ([to pcoll] (write-bq-table-raw to {} pcoll)))


     [^PCollection pcoll]
     (let [schema (:schema options)
           base-coll pcoll]
       (write-bq-table-raw to safe-opts base-coll)))))

(defn write-bq-table
  ([to options ^PCollection pcoll]
