Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defn extract-dataframe-schema
(let [fields (reduce (fn [lst schema-line]
(let [k (first schema-line)
t (if (= (count schema-line) 3) (last schema-line) DataTypes/StringType) ]
(conj lst (DataTypes/createStructField (name k) t NULLABLE)))) [] rec)
arr (ArrayList. fields)]
(DataTypes/createStructType arr)))
(defn as-rows
(let [values (object-array (reduce (fn [lst v] (conj lst v)) [] rec))]
(RowFactory/create values)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment