bigbroda 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a85336962baf88e59b45231a837fba8593239d8c
4
- data.tar.gz: 740fe4fe305e177e8211e89fcf4a678d03f5a26c
3
+ metadata.gz: 6fccea072492e7e4324d86cd6f244edfcb747329
4
+ data.tar.gz: b4ace5514f1fa3321e32e64f3c5d415cd753b1c1
5
5
  SHA512:
6
- metadata.gz: a8e82dbbc195c43b093a26e0d1e166d68cc18f6c819a41b7ea486b0f80e4ec044259fc9971a85c8ba160671a5ea03786f331878d97454c5e15cb984c627096ec
7
- data.tar.gz: 2bcb219c097c31424e136b1a44c498803e730b9132656968f33ac2ed642c83b4d6dc33224428df6655406fddd3ee1bf9b72ba89a48e3726134bfa59d6ff59ec5
6
+ metadata.gz: 5b0f96678ecc0b2434127172dcbb72fecb18e55840b8a2c7b682028fc17605c1f8de6b1b7fc514c39e7a702c11b0b3e3e8122e1faaa1bbd4f51101ac1cd73b18
7
+ data.tar.gz: bd5511d3292c258dc675d9b8771c2aa794e53ad1ac22651c5bccb60da93d20a497d2c2e7ede2fbd6121215652a0f9d0b99c6a6596329f31f9630d1d631899754
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # GoogleBigquery
1
+ # BigBroda
2
2
 
3
- GoogleBig Query ActiveRecord Adapter & standalone API client
3
+ GoogleBigQuery ActiveRecord Adapter & standalone API client
4
4
 
5
5
  ## Use Cases:
6
6
 
@@ -17,7 +17,7 @@ So, use BigQuery as an OLAP (Online Analytical Processing) service, not as OLTP
17
17
 
18
18
  Add 'google_bigquery' to your application's Gemfile or install it yourself as:
19
19
 
20
- $ gem install google_bigquery
20
+ $ gem install bigbroda
21
21
 
22
22
  ## Rails / ActiveRecord:
23
23
 
@@ -126,6 +126,11 @@ see more at: https://developers.google.com/bigquery/query-reference#joins
126
126
  @user.save
127
127
  ```
128
128
 
129
+ ```ruby
130
+ User.create([{name: "miki"}, {name: "jara"}])
131
+
132
+ ```
133
+
129
134
  NOTE: by default the adapter will set Id values as an SecureRandom.hex, and for now all the foreign keys are created as a STRING type
130
135
 
131
136
  #### Deletion and edition of single rows:
@@ -334,7 +334,7 @@ module ActiveRecord
334
334
  def bigquery_load(bucket_location = [])
335
335
  bucket_location = bucket_location.empty? ? ["#{cfg[:database]}/#{table_name}.json"] : bucket_location
336
336
  cfg = connection_config
337
- fields = columns.map{|o| {name: o.name, type: o.type} }
337
+ fields = columns.map{|o| {name: o.name, type: o.sql_type, mode: "nullable" } }
338
338
  GoogleBigquery::Jobs.load(cfg[:project],
339
339
  cfg[:database],
340
340
  table_name,
@@ -57,6 +57,7 @@ module GoogleBigquery
57
57
  end
58
58
 
59
59
  #export data
60
+ #TODO: get mappings for formatting options
60
61
  def self.export(project_id, dataset_id, table_id, bucket_location)
61
62
  body = {'projectId'=> project_id,
62
63
  'configuration'=> {
@@ -77,7 +78,7 @@ module GoogleBigquery
77
78
  :body_object=> body,
78
79
  :parameters=> {"projectId"=> project_id}
79
80
  )
80
-
81
+
81
82
  job_id = JSON.parse(res.body)["jobReference"]["jobId"]
82
83
  puts 'Waiting for export to complete..'
83
84
 
@@ -98,15 +99,15 @@ module GoogleBigquery
98
99
  end
99
100
  end
100
101
 
102
+ #TODO: get mappings for formatting options
101
103
  def self.load(project_id, dataset_id, table_id, sources, fields)
102
104
  body = { 'projectId'=> project_id,
103
105
  'configuration'=> {
104
106
  'load'=> {
107
+ 'sourceFormat' => "NEWLINE_DELIMITED_JSON",
105
108
  'sourceUri' => sources.first,
106
109
  'sourceUris' => sources,
107
- 'schema' => {
108
- "fields"=> fields
109
- },
110
+
110
111
  'destinationTable'=> {
111
112
  'projectId'=> project_id,
112
113
  'datasetId'=> dataset_id,
@@ -1,3 +1,3 @@
1
1
  module GoogleBigquery
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -24,4 +24,4 @@ module GoogleBigquery
24
24
  require File.join(File.dirname(__FILE__), *%w[google_bigquery railtie]) if ::Rails.version.to_s >= '3.1'
25
25
  end
26
26
 
27
- end
27
+ end
@@ -14,26 +14,26 @@
14
14
  ActiveRecord::Schema.define(version: 20140227015551) do
15
15
 
16
16
  create_table "log_data", force: true do |t|
17
- t.string "name"
18
- t.string "description"
19
- t.datetime "created_at"
20
- t.datetime "updated_at"
17
+ t.string "name"
18
+ t.string "description"
19
+ t.timestamp "created_at"
20
+ t.timestamp "updated_at"
21
21
  end
22
22
 
23
23
  create_table "posts", force: true do |t|
24
- t.string "title"
25
- t.integer "user_id"
26
- t.datetime "created_at"
27
- t.datetime "updated_at"
24
+ t.string "title"
25
+ t.string "user_id"
26
+ t.timestamp "created_at"
27
+ t.timestamp "updated_at"
28
28
  end
29
29
 
30
30
  create_table "users", force: true do |t|
31
- t.string "name"
32
- t.boolean "admin"
33
- t.integer "phone"
34
- t.datetime "created_at"
35
- t.datetime "updated_at"
36
- t.string "last_name"
31
+ t.string "name"
32
+ t.boolean "admin"
33
+ t.integer "phone"
34
+ t.timestamp "created_at"
35
+ t.timestamp "updated_at"
36
+ t.string "last_name"
37
37
  end
38
38
 
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigbroda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - miguel michelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler