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
4eae2178
Unverified
Commit
4eae2178
authored
4 years ago
by
Cam Saul
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #13584 from metabase/fix-bq-regression
Wait for initial query to be ready before paginating
parents
cddfe698
109d2224
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/drivers/bigquery/src/metabase/driver/bigquery.clj
+18
-6
18 additions, 6 deletions
modules/drivers/bigquery/src/metabase/driver/bigquery.clj
with
18 additions
and
6 deletions
modules/drivers/bigquery/src/metabase/driver/bigquery.clj
+
18
−
6
View file @
4eae2178
...
...
@@ -152,15 +152,26 @@
"Callback to execute when a new page is retrieved, used for testing"
nil
)
(
defprotocol
GetJobComplete
"A Clojure protocol for the .getJobComplete method on disparate Google BigQuery results"
(
get-job-complete
[
this
]
"Call .getJobComplete on a BigQuery API response"
))
(
extend-protocol
GetJobComplete
com.google.api.services.bigquery.model.QueryResponse
(
get-job-complete
[
this
]
(
.getJobComplete
^
QueryResponse
this
))
com.google.api.services.bigquery.model.GetQueryResultsResponse
(
get-job-complete
[
this
]
(
.getJobComplete
^
GetQueryResultsResponse
this
)))
(
defn
do-with-finished-response
"Impl for `with-finished-response`."
{
:style/indent
1
}
[
^
GetQueryResultsResponse
response
,
f
]
[
response
f
]
;; 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.
(
loop
[
remaining-timeout
(
double
query-timeout-seconds
)]
(
cond
(
.
get
JobC
omplete
response
)
(
get
-job-c
omplete
response
)
(
f
response
)
(
pos?
remaining-timeout
)
...
...
@@ -180,7 +191,7 @@
[[
response-binding
response
]
&
body
]
`
(
do-with-finished-response
~
response
(
fn
[
~
(
vary-meta
response-binding
assoc
:tag
'com.google.api.services.bigquery.model.GetQueryResultsResponse
)
]
(
fn
[
~
response-binding
]
~@
body
)))
(
defn-
^
GetQueryResultsResponse
get-query-results
...
...
@@ -208,15 +219,16 @@
job-ref
(
.getJobReference
query-response
)
job-id
(
.getJobId
job-ref
)
proj-id
(
.getProjectId
job-ref
)]
(
get-query-results
client
proj-id
job-id
nil
))))
(
with-finished-response
[
_
query-response
]
(
get-query-results
client
proj-id
job-id
nil
)))))
(
defn-
post-process-native
"Parse results of a BigQuery query. `respond` is the same function passed to
`metabase.driver/execute-reducible-query`, and has the signature
(respond results-metadata rows)"
[
database
respond
^
QueryResponse
resp
]
(
with-finished-response
[
response
resp
]
[
database
respond
^
Get
QueryRes
ultsRes
ponse
resp
]
(
with-finished-response
[
^
GetQueryResultsResponse
response
resp
]
(
let
[
^
TableSchema
schema
(
.getSchema
response
)
...
...
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