bigquery 0.2.10 → 0.3.0

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: 2a6b70cb84d6ff943f8b0df09c7d78aafdddb60f
4
- data.tar.gz: 31bf68de60cb4f6e10773605f007df26a35d7ae3
3
+ metadata.gz: 20fc5558fdf2c8d418732427cf1224e24a843d90
4
+ data.tar.gz: d9dd7002fb14a039121696cac189995f43a0bca4
5
5
  SHA512:
6
- metadata.gz: 16f52a1058e60c9cf7a9dc89da0c1fd7a0b4ddc5685912cedefef4d68432658eb0aaf9001611e07c97eef8757d529e53ccfbd1e1ce5762488fdec5f1f7e79a26
7
- data.tar.gz: fce727fc5ebfcbe1ef232fc8c32f79a0e7df0351fcb70f131b2c3755e4cc2d8f52347db40d9011d7b29dde8521c39a338c35977edf84640ba8a089218ba747e3
6
+ metadata.gz: 921eff01e2524cbbac496452255425e8ddc6c281500de221aa13a75bc084241117cbd734ddbe50a75b51faf5c27127389e195177c83e92a5cc8b90f27cfb68c6
7
+ data.tar.gz: fd8e7a36683589f98df3dcaf1be567343649c3822b9730f12d4311fdabe2e4c5500b51dfeecaf229bfa69b839b08d35345c1cf7ed09254ecbc88c40f4aea956c
@@ -0,0 +1,4 @@
1
+ # 0.3.0
2
+ * Added support to insert to allow for array of rows
3
+ * Locked the google-api-client gem to ~> 0.7.X
4
+ * Added a possible work around to #13
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bigquery (0.2.9)
5
- google-api-client (>= 0.4.6)
4
+ bigquery (0.3.0)
5
+ google-api-client (~> 0.7.1)
6
+ retriable (~> 1.4)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -32,8 +33,9 @@ GEM
32
33
  retriable (>= 1.4)
33
34
  signet (>= 0.5.0)
34
35
  uuidtools (>= 2.1.0)
35
- jwt (1.0.0)
36
- launchy (2.4.2)
36
+ jwt (0.1.5)
37
+ multi_json (>= 1.0)
38
+ launchy (2.4.3)
37
39
  addressable (~> 2.3)
38
40
  method_source (0.8.2)
39
41
  minitest (5.3.4)
@@ -54,7 +56,7 @@ GEM
54
56
  jwt (>= 0.1.5)
55
57
  multi_json (>= 1.0.0)
56
58
  slop (3.5.0)
57
- uuidtools (2.1.4)
59
+ uuidtools (2.1.5)
58
60
 
59
61
  PLATFORMS
60
62
  ruby
data/README.md CHANGED
@@ -57,7 +57,7 @@ Create table. First param is the table name second one is the table schema defin
57
57
 
58
58
  {
59
59
  field_name: {
60
- type: 'TYPE_VALUE BETWEEN (STRING, INTEGER, FLOAT, BOOLEAN, RECORD)',
60
+ type: 'TYPE_VALUE BETWEEN (STRING, INTEGER, FLOAT, BOOLEAN, RECORD, TIMESTAMP)',
61
61
  mode: 'MODE_VALUE BETWEEN (NULLABLE, REQUIRED, REPEATED)'
62
62
  },
63
63
  other_field_name: { ... }
@@ -75,15 +75,20 @@ Describe table schema
75
75
 
76
76
  bq.describe_table('table_name')
77
77
 
78
- ## Query
79
-
80
- You can either select
78
+ ## Querying
81
79
 
82
80
  bq.query("SELECT * FROM [#{config['dataset']}.table_name] LIMIT 1")
83
81
 
84
- Or insert
82
+ ## Inserting
83
+
84
+ Insert a single row
85
85
 
86
86
  bq.insert('table_name', 'id' => 123, 'type' => 'Task')
87
+
88
+ Batch insert an array of rows. [See bigquery docs for limitations.](https://cloud.google.com/bigquery/streaming-data-into-bigquery#quota)
89
+
90
+ data = [{'id' => 123, 'type' => 'Foo'}, {'id' => 321, 'type' => 'Bar'}]
91
+ bq.insert('table_name', data)
87
92
 
88
93
  ## Keys
89
94
 
@@ -15,7 +15,10 @@ Gem::Specification.new do |s|
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
 
18
- s.add_dependency "google-api-client", ">= 0.4.6"
18
+ # current sort of workaround. see issue#13
19
+ s.add_dependency "retriable", "~> 1.4"
20
+
21
+ s.add_dependency "google-api-client", "~> 0.7.1"
19
22
 
20
23
  s.add_development_dependency "bundler"
21
24
  s.add_development_dependency "rake"
@@ -4,7 +4,7 @@
4
4
  module BigQuery
5
5
  class Client
6
6
  module Tables
7
- ALLOWED_FIELD_TYPES = ['STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'RECORD']
7
+ ALLOWED_FIELD_TYPES = ['STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'RECORD', 'TIMESTAMP']
8
8
  ALLOWED_FIELD_MODES = ['NULLABLE', 'REQUIRED', 'REPEATED']
9
9
 
10
10
  # Lists the tables
@@ -46,11 +46,17 @@ module BigQuery
46
46
  # @param opts [Hash] field value hash to be inserted
47
47
  # @return [Hash]
48
48
  def insert(tableId, opts)
49
+ if opts.class == Array
50
+ body = { 'rows' => opts = opts.map{|x| {"json" => x}} }
51
+ else
52
+ body = { 'rows' => [{ 'json' => opts }] }
53
+ end
54
+
49
55
  api(
50
56
  api_method: @bq.tabledata.insert_all,
51
57
  parameters: { 'tableId' => tableId,
52
58
  'datasetId' => @dataset },
53
- body_object: { 'rows' => [{ 'json' => opts }] }
59
+ body_object: body
54
60
  )
55
61
  end
56
62
 
@@ -1,3 +1,3 @@
1
1
  module BigQuery
2
- VERSION = '0.2.10'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -88,4 +88,15 @@ class BigQueryTest < MiniTest::Unit::TestCase
88
88
 
89
89
  assert_equal result['kind'], "bigquery#tableDataInsertAllResponse"
90
90
  end
91
+
92
+ def test_for_insert_array
93
+ data = [
94
+ {"id" => 123, "type" => "Task"},
95
+ {"id" => 321, "type" => "Other task"}
96
+ ]
97
+
98
+ result = @bq.insert('test' , data)
99
+
100
+ assert_equal result['kind'], "bigquery#tableDataInsertAllResponse"
101
+ end
91
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Bronte
@@ -9,22 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-23 00:00:00.000000000 Z
12
+ date: 2014-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: retriable
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.4'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.4'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: google-api-client
16
30
  requirement: !ruby/object:Gem::Requirement
17
31
  requirements:
18
- - - ">="
32
+ - - "~>"
19
33
  - !ruby/object:Gem::Version
20
- version: 0.4.6
34
+ version: 0.7.1
21
35
  type: :runtime
22
36
  prerelease: false
23
37
  version_requirements: !ruby/object:Gem::Requirement
24
38
  requirements:
25
- - - ">="
39
+ - - "~>"
26
40
  - !ruby/object:Gem::Version
27
- version: 0.4.6
41
+ version: 0.7.1
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: bundler
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +106,7 @@ extensions: []
92
106
  extra_rdoc_files: []
93
107
  files:
94
108
  - ".gitignore"
109
+ - CHANGELOG.md
95
110
  - Gemfile
96
111
  - Gemfile.lock
97
112
  - README.md
@@ -132,4 +147,3 @@ specification_version: 4
132
147
  summary: A nice wrapper for Google Big Query
133
148
  test_files:
134
149
  - test/bigquery.rb
135
- has_rdoc: