Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit ee4ff64

Browse files
authored
Pass job location as part of paginated queries if set (#34)
1 parent c5ee540 commit ee4ff64

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
include:
1616
- pair:
17-
elixir: '1.12'
17+
elixir: '1.15'
1818
otp: 24
1919
lint: lint
2020
steps:

lib/req_bigquery.ex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,13 @@ defmodule ReqBigQuery do
255255

256256
%{
257257
"pageToken" => page_token,
258-
"jobReference" => %{"jobId" => job_id, "projectId" => project_id}
258+
"jobReference" => job_reference
259259
} ->
260-
resp = page_request(request_options, project_id, job_id, page_token)
260+
%{"jobId" => job_id, "projectId" => project_id} = job_reference
261+
262+
job_location = Map.get(job_reference, "location")
263+
264+
resp = page_request(request_options, project_id, job_id, job_location, page_token)
261265
{resp.body["rows"], resp.body}
262266

263267
_end ->
@@ -267,12 +271,18 @@ defmodule ReqBigQuery do
267271
|> Stream.flat_map(& &1)
268272
end
269273

270-
defp page_request(options, project_id, job_id, page_token) do
274+
defp page_request(options, project_id, job_id, job_location, page_token) do
271275
uri =
272276
URI.parse(
273277
"#{@base_url}/projects/#{project_id}/queries/#{job_id}?maxResults=#{options[:max_results]}&pageToken=#{page_token}"
274278
)
275279

280+
uri =
281+
case job_location do
282+
nil -> uri
283+
job_location -> URI.append_query(uri, "location=#{job_location}")
284+
end
285+
276286
token = Goth.fetch!(options[:goth]).token
277287

278288
Req.new(url: uri)

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule ReqBigQuery.MixProject do
1010
version: @version,
1111
description: @description,
1212
name: "ReqBigQuery",
13-
elixir: "~> 1.12",
13+
elixir: "~> 1.15",
1414
preferred_cli_env: [
1515
"test.all": :test,
1616
docs: :docs,

0 commit comments

Comments
 (0)