bigbroda 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/active_record/connection_adapters/bigquery_adapter.rb +1 -1
- data/lib/google_bigquery/jobs.rb +5 -4
- data/lib/google_bigquery/version.rb +1 -1
- data/lib/google_bigquery.rb +1 -1
- data/spec/dummy/db/schema.rb +14 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fccea072492e7e4324d86cd6f244edfcb747329
|
4
|
+
data.tar.gz: b4ace5514f1fa3321e32e64f3c5d415cd753b1c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b0f96678ecc0b2434127172dcbb72fecb18e55840b8a2c7b682028fc17605c1f8de6b1b7fc514c39e7a702c11b0b3e3e8122e1faaa1bbd4f51101ac1cd73b18
|
7
|
+
data.tar.gz: bd5511d3292c258dc675d9b8771c2aa794e53ad1ac22651c5bccb60da93d20a497d2c2e7ede2fbd6121215652a0f9d0b99c6a6596329f31f9630d1d631899754
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# BigBroda
|
2
2
|
|
3
|
-
|
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
|
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.
|
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,
|
data/lib/google_bigquery/jobs.rb
CHANGED
@@ -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
|
-
|
108
|
-
"fields"=> fields
|
109
|
-
},
|
110
|
+
|
110
111
|
'destinationTable'=> {
|
111
112
|
'projectId'=> project_id,
|
112
113
|
'datasetId'=> dataset_id,
|
data/lib/google_bigquery.rb
CHANGED
data/spec/dummy/db/schema.rb
CHANGED
@@ -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
|
18
|
-
t.string
|
19
|
-
t.
|
20
|
-
t.
|
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
|
25
|
-
t.
|
26
|
-
t.
|
27
|
-
t.
|
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
|
32
|
-
t.boolean
|
33
|
-
t.integer
|
34
|
-
t.
|
35
|
-
t.
|
36
|
-
t.string
|
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.
|
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-
|
11
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|