Skip to content

Commit 33061c9

Browse files
authored
Merge pull request #4 from YujiKoyano/bug-fix/access-rows-with-symbol-2
add-method-converting-string-to-symbol
2 parents e229410 + 21109bd commit 33061c9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/embulk/input/bigquery.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def self.transaction(config, &control)
5050
def run
5151
bq = Google::Cloud::Bigquery.new(project: @task[:project], keyfile: @task[:keyfile])
5252
params = @task[:params]
53+
@task[:columns] = values_to_sym(@task[:columns], 'name')
5354
option = keys_to_sym(@task[:option])
5455
rows = bq.query(@task[:sql], **option)
5556
rows.each do |row|
@@ -68,7 +69,13 @@ def run
6869
return {}
6970
end
7071

71-
def keys_to_sym(hash)
72+
def values_to_sym(hashs, key)
73+
hashs.map do |h|
74+
h[key] = h[key].to_sym
75+
h
76+
end
77+
78+
def keys_to_sym(hash)
7279
ret = {}
7380
hash.each do |key, value|
7481
ret[key.to_sym] = value

0 commit comments

Comments
 (0)