bigquery-client 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4618e20772e4a20b5cccc5dab6cf62118601a1e
4
- data.tar.gz: a8df1ed4209739ac5c8fabe882f6168e930b8810
3
+ metadata.gz: 9a86e09fec3bb6175a2d99264a10a139b742f14c
4
+ data.tar.gz: 475d160a52fbf704d02d34ceaaaaf689e6286ae0
5
5
  SHA512:
6
- metadata.gz: 5cc6a3968a30eeea0206c01b1bfebd0f18739711052522a9211b0b6baf98e9770f36467157cd3e0383b4e0b05e5b7ce5ff901a84663c402cd519d0c9e89a16d7
7
- data.tar.gz: fbefdeda12a0bd2fb0dda5e914ead935a7402be8e8ca3d156a9d71ab4417a535e2ce5b58dc2bc78ad7426a3413d23e77f6d5b20719e29d86ee9e1557c3e84e8b
6
+ metadata.gz: 331ef756470a6586af5eb37dee614532cf1df20873fae4c12dff16207b2c087b17092771c26007137bdffac43dfc8556d550979286ab1b0be3087388109eb610
7
+ data.tar.gz: 960d58359bfd5a9687ca9a313be7a963f113fe2c948dde6f765e07199548ca93cda707332fc588ec9cc3748572ec1cafb748647495ee2ab0f12cd1ac4fcb8a13
@@ -6,7 +6,7 @@ module BigQuery
6
6
  result = jobs_query(query, options)
7
7
  names = result['schema']['fields'].map {|field| field['name'] }
8
8
  types = result['schema']['fields'].map {|field| field['type'] }
9
- records = result['rows'].map {|row| row['f'].map {|record| record['v'] } }
9
+ records = (result['rows'] || []).map {|row| row['f'].map {|record| record['v'] } }
10
10
  convert(records, types).map { |values| [names, values].transpose.to_h }
11
11
  end
12
12
 
@@ -1,5 +1,5 @@
1
1
  module BigQuery
2
2
  class Client
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  end
@@ -12,11 +12,27 @@ class JobsTest < Test::Unit::TestCase
12
12
  100
13
13
  EOS
14
14
 
15
+ @@no_rows_query = <<-"EOS"
16
+ SELECT
17
+ born_alive_alive, mother_residence_state, is_male
18
+ FROM
19
+ publicdata:samples.natality
20
+ ORDER BY
21
+ day
22
+ LIMIT
23
+ 0
24
+ EOS
25
+
15
26
  def test_sql
16
27
  result = $client.sql(@@query)
17
28
  assert { result.size == 100 }
18
29
  assert { result.sample["born_alive_alive"].is_a? Fixnum }
19
30
  assert { result.sample["mother_residence_state"].is_a? String }
20
- assert { result.sample["is_male"] == true || result.first["is_male"] == false }
31
+ assert { result.first["is_male"] == true || result.first["is_male"] == false }
32
+ end
33
+
34
+ def test_sql_when_no_rows
35
+ result = $client.sql(@@no_rows_query)
36
+ assert { result == [] }
21
37
  end
22
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigquery-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsukuru Tanimichi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client