Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
8c63e406
Commit
8c63e406
authored
9 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
auto-retry BQ table-row-count in case it times out
parent
b553b0b5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/driver/bigquery.clj
+2
-2
2 additions, 2 deletions
src/metabase/driver/bigquery.clj
test/metabase/test/data/bigquery.clj
+7
-3
7 additions, 3 deletions
test/metabase/test/data/bigquery.clj
with
9 additions
and
5 deletions
src/metabase/driver/bigquery.clj
+
2
−
2
View file @
8c63e406
...
...
@@ -182,12 +182,12 @@
"TIMESTAMP"
parse-timestamp-str
})
(
def
^
:private
^
:const
query-timeout-error-message
"Query timed out."
)
(
def
^
:private
^
:const
query-default-timeout-seconds
3
0
)
(
def
^
:private
^
:const
query-default-timeout-seconds
2
0
)
(
defn-
post-process-native
([
^
QueryResponse
response
]
(
post-process-native
response
query-default-timeout-seconds
))
([
^
QueryResponse
response,
^
Integer
timeout-seconds
]
([
^
QueryResponse
response,
^
Integer
timeout-seconds
,
should-retry?
]
(
if-not
(
.getJobComplete
response
)
;; 99% of the time by the time this is called `.getJobComplete` will return `true`. On the off chance it doesn't, wait a few seconds for the job to finish.
(
do
...
...
This diff is collapsed.
Click to expand it.
test/metabase/test/data/bigquery.clj
+
7
−
3
View file @
8c63e406
...
...
@@ -90,9 +90,13 @@
(
println
(
u/format-color
'blue
"Created BigQuery table '%s.%s'."
dataset-id
table-id
)))
(
defn-
table-row-count
^
Integer
[
^
String
dataset-id,
^
String
table-id
]
(
first
(
first
(
:rows
(
post-process-native
(
execute
(
.query
(
.jobs
bigquery
)
project-id
(
doto
(
QueryRequest.
)
(
.setQuery
(
format
"SELECT COUNT(*) FROM [%s.%s]"
dataset-id
table-id
))))))))))
(
let
[
f
(
fn
[]
(
first
(
first
(
:rows
(
post-process-native
(
execute
(
.query
(
.jobs
bigquery
)
project-id
(
doto
(
QueryRequest.
)
(
.setQuery
(
format
"SELECT COUNT(*) FROM [%s.%s]"
dataset-id
table-id
))))))))))]
;; automatically retry the query in case it fails / times out
(
try
(
f
)
(
catch
Throwable
_
(
f
)))))
;; This is a dirty HACK
(
defn-
^
DateTime
timestamp-korma-form->GoogleDateTime
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment