Skip to content
Snippets Groups Projects
Commit f063a349 authored by Cam Saül's avatar Cam Saül
Browse files

More BigQuery CI tweaks :cry:

parent bc99be45
Branches
Tags
No related merge requests found
......@@ -33,20 +33,25 @@
(def ^:private ^:const ^String redirect-uri "urn:ietf:wg:oauth:2.0:oob")
(defn- execute-no-auto-retry
"`execute` REQUEST, and catch any `GoogleJsonResponseException` is
throws, converting them to `ExceptionInfo` and rethrowing them."
[^AbstractGoogleClientRequest request]
(try (.execute request)
(catch GoogleJsonResponseException e
(let [^GoogleJsonError error (.getDetails e)]
(throw (ex-info (or (.getMessage error)
(.getStatusMessage e))
(into {} error)))))))
(defn- execute
"`execute` REQUEST, and catch any `GoogleJsonResponseException` is
throws, converting them to `ExceptionInfo` and rethrowing them.
This automatically retries any failed requests a single time."
This automatically retries any failed requests up to 2 times."
[^AbstractGoogleClientRequest request]
;; automatically retry each request at least once if it fails
(u/auto-retry 1
(try (.execute request)
(catch GoogleJsonResponseException e
(let [^GoogleJsonError error (.getDetails e)]
(throw (ex-info (or (.getMessage error)
(.getStatusMessage e))
(into {} error))))))))
(u/auto-retry 2
(execute-no-auto-retry request)))
(defn- ^Bigquery credential->client [^GoogleCredential credential]
(.build (doto (Bigquery$Builder. http-transport json-factory credential)
......@@ -185,7 +190,7 @@
"STRING" identity
"TIMESTAMP" parse-timestamp-str})
(def ^:private ^:const query-default-timeout-seconds 15)
(def ^:private ^:const query-default-timeout-seconds 30)
(defn- post-process-native
([^QueryResponse response]
......
......@@ -14,7 +14,7 @@
(com.google.api.services.bigquery.model Dataset DatasetReference QueryRequest Table TableDataInsertAllRequest TableDataInsertAllRequest$Rows TableFieldSchema TableReference TableRow TableSchema)
metabase.driver.bigquery.BigQueryDriver))
(resolve-private-fns metabase.driver.bigquery execute post-process-native)
(resolve-private-fns metabase.driver.bigquery execute execute-no-auto-retry post-process-native)
;;; # ------------------------------------------------------------ CONNECTION DETAILS ------------------------------------------------------------
......@@ -67,8 +67,8 @@
(defn- destroy-dataset! [^String dataset-id]
{:pre [(seq dataset-id)]}
(execute (doto (.delete (.datasets bigquery) project-id dataset-id)
(.setDeleteContents true)))
(execute-no-auto-retry (doto (.delete (.datasets bigquery) project-id dataset-id)
(.setDeleteContents true)))
(println (u/format-color 'red "Deleted BigQuery dataset '%s'." dataset-id)))
(def ^:private ^:const valid-field-types
......@@ -179,7 +179,7 @@
{:pre [(seq database-name) (sequential? table-definitions)]}
(let [database-name (normalize-name-and-add-prefix database-name)]
(when-not (contains? @created-databases database-name)
(u/auto-retry 2
(u/auto-retry 3
(u/ignore-exceptions
(destroy-dataset! database-name))
(create-dataset! database-name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment