I’m using Java Google BigQuery interop ([com.google.cloud/google-cloud-bigquery "2.16.0"]
) and I’m trying to convert/return the data as a vector of maps.
The new-map
value has data, however, the results
data seems empty.
(defn find-by-range [^String start-date ^String end-date]
{:pre [(some? start-date) (some? end-date)]}
(let [^String query (find-by-range-sql start-date end-date)
^BigQuery big-query (.getService (BigQueryOptions/getDefaultInstance))
^QueryJobConfiguration query-config (.build (QueryJobConfiguration/newBuilder query))
^TableResult table-result (.query big-query query-config (into-array BigQuery$JobOption []))
results []]
(doseq [row (.iterateAll table-result)]
(let [^String id (.getStringValue (.get row "id"))
^String created-at (.getStringValue (.get row "created_at"))
new-map {:id id :created-at created-at}
results (into results new-map)]))
results))
(defn -main
[& args]
(let [start-date "2022-07-26T00:00:00"
end-date "2022-07-26T23:59:59"
data (find-by-range start-date end-date)]
(doseq [row data]
(println row))))
The error:
Syntax error (NullPointerException) compiling at (/private/var/folders/j3/zqjvh17x5hz0d87m0wtkq6cm0000gn/T/form-init16919376317410822441.clj:1:126).
null
What am I doing wrong?