bigquery 0.4.0 → 0.5.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: 6982c1cc6c0aa808ef9f46d125de87294bd2e30e
4
- data.tar.gz: 8a466b535aa30ebc3314cdb01a2f6e09876cd659
3
+ metadata.gz: f1780273af1d1592bd9fc5b75bc529c655d80b26
4
+ data.tar.gz: 73b136d9c55bf6976589f866ffed0366fa7cd005
5
5
  SHA512:
6
- metadata.gz: d97e7043f9f7ad3719398e555702a3ca6551baa25f2dbe1389bbec26c5934b1af188f0a7e505ff6f23eb9fc02fc7f52caf8ed5b5fcb26b75f51feaa56d198a70
7
- data.tar.gz: f17749dd5a100d85c7c9adb0aff5780e4bd6d098b0ac73bb5e0c684649fa0e812b6422d3d28789ad516e4dcc557ad3e53c9ccd2a70be715e73b25f499bd21d84
6
+ metadata.gz: f2447f0bfec5ff4bee75e6593c4ee26e16832236ef42fa40c956d3d6e49e9669d9f9f6eb5f3065e62a03e7583c1b3e744764ef5be13c28e0e3c26bde301a3f6d
7
+ data.tar.gz: 4530e664ed3d3869210ecebb5f6aed94c5c674371b77edbcba4c2c93edc4f0a17b9dc756c5e54172432f07b639c34cae0f68d8f5df335f31a558ddc566268644
data/README.md CHANGED
@@ -18,6 +18,7 @@ Only service accounts are supported right now. https://developers.google.com/acc
18
18
  * tables_formatted
19
19
  * job
20
20
  * jobs
21
+ * insert_job
21
22
  * refresh_auth
22
23
 
23
24
  ## Example
@@ -121,6 +121,9 @@ module BigQuery
121
121
  mode = (ALLOWED_FIELD_MODES & [options[:mode].to_s]).first
122
122
  field = { "name" => name.to_s, "type" => type }
123
123
  field["mode"] = mode if mode
124
+ if field["type"] == 'RECORD'
125
+ field["fields"] = validate_schema(options[:fields])
126
+ end
124
127
  fields << field
125
128
  end
126
129
  fields
@@ -1,3 +1,3 @@
1
1
  module BigQuery
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
data/test/bigquery.rb CHANGED
@@ -20,11 +20,10 @@ class BigQueryTest < MiniTest::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_for_tables
23
- tables = @bq.tables
23
+ table = @bq.tables.select{|t| t['id'] == "#{config['project_id']}:#{config['dataset']}.test"}.first
24
24
 
25
- assert_equal tables[0]['kind'], "bigquery#table"
26
- assert_equal tables[0]['id'], "#{config['project_id']}:#{config['dataset']}.test"
27
- assert_equal tables[0]['tableReference']['tableId'], 'test'
25
+ assert_equal table['kind'], "bigquery#table"
26
+ assert_equal table['tableReference']['tableId'], 'test'
28
27
  end
29
28
 
30
29
  def test_for_tables_formatted
@@ -43,11 +42,39 @@ class BigQueryTest < MiniTest::Unit::TestCase
43
42
  if @bq.tables_formatted.include? 'test123'
44
43
  @bq.delete_table('test123')
45
44
  end
46
- result = @bq.create_table('test123', id: { type: 'INTEGER' })
45
+
46
+ schema = {
47
+ id: { type: 'INTEGER'},
48
+ city: {
49
+ name:"city",
50
+ type:"RECORD",
51
+ mode: "nullable",
52
+ fields: {
53
+ id: {name:"id", type:"INTEGER" },
54
+ name: {name:"name", type:"STRING" },
55
+ country: { name:"country", type:"STRING" },
56
+ time: { name:"time", type:"TIMESTAMP" }
57
+ }
58
+ }
59
+ }
60
+
61
+ result = @bq.create_table('test123', schema)
47
62
 
48
63
  assert_equal result['kind'], "bigquery#table"
49
64
  assert_equal result['tableReference']['tableId'], "test123"
50
- assert_equal result['schema']['fields'], [{"name"=>"id", "type"=>"INTEGER"}]
65
+ assert_equal result['schema']['fields'], [
66
+ {"name"=>"id", "type"=>"INTEGER"},
67
+ {
68
+ "name"=>"city",
69
+ "type"=>"RECORD",
70
+ "fields"=>[
71
+ {"name"=>"id", "type"=>"INTEGER"},
72
+ {"name"=>"name", "type"=>"STRING"},
73
+ {"name"=>"country", "type"=>"STRING"},
74
+ {"name"=>"time", "type"=>"TIMESTAMP"}
75
+ ]
76
+ }
77
+ ]
51
78
  end
52
79
 
53
80
  def test_for_delete_table
@@ -101,7 +128,7 @@ class BigQueryTest < MiniTest::Unit::TestCase
101
128
  end
102
129
 
103
130
  def test_for_insert_job
104
- res = @bq.insert_job(query: {query: "SELECT * FROM [#{config['dataset']}.test] LIMIT 1"})
131
+ result = @bq.insert_job(query: {query: "SELECT * FROM [#{config['dataset']}.test] LIMIT 1"})
105
132
 
106
133
  assert_equal result['kind'], "bigquery#job"
107
134
  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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Bronte
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-29 00:00:00.000000000 Z
12
+ date: 2015-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: retriable