Skip to content

Commit 4dd6565

Browse files
committed
add method and optional variable for optional configuration
1 parent f82ded1 commit 4dd6565

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lib/embulk/input/bigquery.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ def self.transaction(config, &control)
2626
keyfile: config[:keyfile],
2727
sql: sql,
2828
columns: config[:columns],
29-
params: params
29+
params: params,
30+
option: {
31+
max: config[:max],
32+
cache: config[:cache],
33+
timeout: config[:timeout],
34+
dryrun: config[:dryrun]
35+
standard_sql: config[:standard_sql],
36+
legacy_sql: config[:legacy_sql]
37+
}
3038
}
3139

3240
columns = []
@@ -42,7 +50,8 @@ def self.transaction(config, &control)
4250
def run
4351
bq = Google::Cloud::Bigquery.new(project: @task[:project], keyfile: @task[:keyfile])
4452
params = @task[:params]
45-
rows = bq.query(@task[:sql])
53+
option = keys_to_sym(@task[:option])
54+
rows = bq.query(@task[:sql], **option)
4655
rows.each do |row|
4756
columns = []
4857
@task[:columns].each do |c|
@@ -58,6 +67,14 @@ def run
5867
@page_builder.finish
5968
return {}
6069
end
70+
71+
def keys_to_sym(hash)
72+
ret = {}
73+
hash.each do |key, value|
74+
ret[key.to_sym] = value
75+
end
76+
ret
77+
end
6178
end
6279
end
6380
end

0 commit comments

Comments
 (0)