bigquery-client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +4 -1
- data/lib/bigquery-client.rb +5 -0
- data/lib/bigquery-client/client.rb +6 -40
- data/lib/bigquery-client/datasets.rb +6 -0
- data/lib/bigquery-client/jobs.rb +6 -0
- data/lib/bigquery-client/projects.rb +6 -0
- data/lib/bigquery-client/tabledata.rb +19 -0
- data/lib/bigquery-client/tables.rb +78 -0
- data/lib/bigquery-client/version.rb +1 -1
- metadata +26 -38
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c980f0639eae7a6531f6da8685f0bcb383afa3b
|
4
|
+
data.tar.gz: abd414579e6962e0ee7a4767f1b6093ad1973779
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15b6cd2dff964d1d59e6443727a7c2cd52e556bb540c08e571df06d78b1fc73daca4c41a64d4a6d55f63b9728d235de18706b2ac2be70c4a3c7727a6ccd98a46
|
7
|
+
data.tar.gz: a92d722dfdf1f444bb9141537c367226537c93e727f9f72578f7d381e9c01cbb3bab04f3ff8806c23d6c4e508a446b5d415f32d116e44941a223c8fff7019dd5
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# BigQuery Client
|
1
|
+
# BigQuery Client
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/bigquery-client.svg)](http://badge.fury.io/rb/bigquery-client)
|
4
|
+
[![Build Status](https://travis-ci.org/ttanimichi/bigquery-client.svg)](https://travis-ci.org/ttanimichi/bigquery-client)
|
2
5
|
|
3
6
|
A Ruby interface to the BigQuery API.
|
4
7
|
|
data/lib/bigquery-client.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
require 'bigquery-client/datasets'
|
2
|
+
require 'bigquery-client/jobs'
|
3
|
+
require 'bigquery-client/projects'
|
4
|
+
require 'bigquery-client/tabledata'
|
5
|
+
require 'bigquery-client/tables'
|
1
6
|
require 'bigquery-client/client'
|
2
7
|
require 'bigquery-client/errors'
|
3
8
|
require 'bigquery-client/version'
|
@@ -6,50 +6,16 @@ require 'google/api_client/auth/compute_service_account'
|
|
6
6
|
|
7
7
|
module BigQuery
|
8
8
|
class Client
|
9
|
+
include BigQuery::Datasets
|
10
|
+
include BigQuery::Jobs
|
11
|
+
include BigQuery::Projects
|
12
|
+
include BigQuery::Tabledata
|
13
|
+
include BigQuery::Tables
|
14
|
+
|
9
15
|
def initialize(attributes = {})
|
10
16
|
attributes.each { |name, value| instance_variable_set("@#{name}", value) }
|
11
17
|
end
|
12
18
|
|
13
|
-
def insert(table, args)
|
14
|
-
rows = args.is_a?(Array) ? args : [args]
|
15
|
-
result = access_api(
|
16
|
-
api_method: bigquery.tabledata.insert_all,
|
17
|
-
parameters: {
|
18
|
-
tableId: table
|
19
|
-
},
|
20
|
-
body_object: {
|
21
|
-
rows: rows.map { |row| { json: row } }
|
22
|
-
}
|
23
|
-
)
|
24
|
-
handle_error(result) if result.error?
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_table(name, schema)
|
28
|
-
result = access_api(
|
29
|
-
api_method: bigquery.tables.insert,
|
30
|
-
body_object: {
|
31
|
-
tableReference: {
|
32
|
-
tableId: name
|
33
|
-
},
|
34
|
-
schema: {
|
35
|
-
fields: schema
|
36
|
-
}
|
37
|
-
}
|
38
|
-
)
|
39
|
-
handle_error(result) if result.error?
|
40
|
-
end
|
41
|
-
|
42
|
-
def fetch_schema(table)
|
43
|
-
result = access_api(
|
44
|
-
api_method: bigquery.tables.get,
|
45
|
-
parameters: {
|
46
|
-
tableId: table
|
47
|
-
}
|
48
|
-
)
|
49
|
-
handle_error(result) if result.error?
|
50
|
-
JSON.parse(result.body)['schema']['fields']
|
51
|
-
end
|
52
|
-
|
53
19
|
private
|
54
20
|
|
55
21
|
def access_api(params = {})
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# https://cloud.google.com/bigquery/docs/reference/v2/tabledata
|
2
|
+
|
3
|
+
module BigQuery
|
4
|
+
module Tabledata
|
5
|
+
def insert(table, args)
|
6
|
+
rows = args.is_a?(Array) ? args : [args]
|
7
|
+
result = access_api(
|
8
|
+
api_method: bigquery.tabledata.insert_all,
|
9
|
+
parameters: {
|
10
|
+
tableId: table
|
11
|
+
},
|
12
|
+
body_object: {
|
13
|
+
rows: rows.map { |row| { json: row } }
|
14
|
+
}
|
15
|
+
)
|
16
|
+
handle_error(result) if result.error?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# https://cloud.google.com/bigquery/docs/reference/v2/tables
|
2
|
+
|
3
|
+
module BigQuery
|
4
|
+
module Tables
|
5
|
+
def create_table(name, schema)
|
6
|
+
result = access_api(
|
7
|
+
api_method: bigquery.tables.insert,
|
8
|
+
body_object: {
|
9
|
+
tableReference: {
|
10
|
+
tableId: name
|
11
|
+
},
|
12
|
+
schema: {
|
13
|
+
fields: schema
|
14
|
+
}
|
15
|
+
}
|
16
|
+
)
|
17
|
+
handle_error(result) if result.error?
|
18
|
+
end
|
19
|
+
|
20
|
+
def list_tables(options = {})
|
21
|
+
result = access_api(
|
22
|
+
api_method: bigquery.tables.list,
|
23
|
+
parameters: options
|
24
|
+
)
|
25
|
+
handle_error(result) if result.error?
|
26
|
+
JSON.parse(result.body)
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_table(name, options = {})
|
30
|
+
result = access_api(
|
31
|
+
api_method: bigquery.tables.update,
|
32
|
+
parameters: {
|
33
|
+
tableId: name
|
34
|
+
},
|
35
|
+
body_object: options
|
36
|
+
)
|
37
|
+
handle_error(result) if result.error?
|
38
|
+
JSON.parse(result.body)
|
39
|
+
end
|
40
|
+
|
41
|
+
def patch_table(name, options = {})
|
42
|
+
result = access_api(
|
43
|
+
api_method: bigquery.tables.patch,
|
44
|
+
parameters: {
|
45
|
+
tableId: name
|
46
|
+
},
|
47
|
+
body_object: options
|
48
|
+
)
|
49
|
+
handle_error(result) if result.error?
|
50
|
+
JSON.parse(result.body)
|
51
|
+
end
|
52
|
+
|
53
|
+
def fetch_schema(table)
|
54
|
+
fetch_table_info(table)['schema']['fields']
|
55
|
+
end
|
56
|
+
|
57
|
+
def fetch_table_info(table)
|
58
|
+
result = access_api(
|
59
|
+
api_method: bigquery.tables.get,
|
60
|
+
parameters: {
|
61
|
+
tableId: table
|
62
|
+
}
|
63
|
+
)
|
64
|
+
handle_error(result) if result.error?
|
65
|
+
JSON.parse(result.body)
|
66
|
+
end
|
67
|
+
|
68
|
+
def drop_table(name)
|
69
|
+
result = access_api(
|
70
|
+
api_method: bigquery.tables.delete,
|
71
|
+
parameters: {
|
72
|
+
tableId: name
|
73
|
+
}
|
74
|
+
)
|
75
|
+
handle_error(result) if result.error?
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
CHANGED
@@ -1,110 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigquery-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tsukuru Tanimichi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2015-
|
11
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: google-api-client
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.8.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.8.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bundler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rr
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: test-unit
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- - ~>
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: 3.0.2
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- - ~>
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: 3.0.2
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: test-unit-rr
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- - ~>
|
87
|
+
- - "~>"
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: 1.0.3
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- - ~>
|
94
|
+
- - "~>"
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: 1.0.3
|
110
97
|
description:
|
@@ -114,8 +101,8 @@ executables: []
|
|
114
101
|
extensions: []
|
115
102
|
extra_rdoc_files: []
|
116
103
|
files:
|
117
|
-
- .gitignore
|
118
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
119
106
|
- Gemfile
|
120
107
|
- LICENSE.txt
|
121
108
|
- README.md
|
@@ -123,37 +110,38 @@ files:
|
|
123
110
|
- bigquery-client.gemspec
|
124
111
|
- lib/bigquery-client.rb
|
125
112
|
- lib/bigquery-client/client.rb
|
113
|
+
- lib/bigquery-client/datasets.rb
|
126
114
|
- lib/bigquery-client/errors.rb
|
115
|
+
- lib/bigquery-client/jobs.rb
|
116
|
+
- lib/bigquery-client/projects.rb
|
117
|
+
- lib/bigquery-client/tabledata.rb
|
118
|
+
- lib/bigquery-client/tables.rb
|
127
119
|
- lib/bigquery-client/version.rb
|
128
120
|
- test/helper.rb
|
129
121
|
- test/test_client.rb
|
130
122
|
homepage: https://github.com/ttanimichi/bigquery-client
|
131
123
|
licenses:
|
132
124
|
- MIT
|
125
|
+
metadata: {}
|
133
126
|
post_install_message:
|
134
127
|
rdoc_options: []
|
135
128
|
require_paths:
|
136
129
|
- lib
|
137
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
131
|
requirements:
|
140
|
-
- -
|
132
|
+
- - ">="
|
141
133
|
- !ruby/object:Gem::Version
|
142
134
|
version: 1.9.3
|
143
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
-
none: false
|
145
136
|
requirements:
|
146
|
-
- -
|
137
|
+
- - ">="
|
147
138
|
- !ruby/object:Gem::Version
|
148
139
|
version: '0'
|
149
|
-
segments:
|
150
|
-
- 0
|
151
|
-
hash: -1636212372983959579
|
152
140
|
requirements: []
|
153
141
|
rubyforge_project:
|
154
|
-
rubygems_version:
|
142
|
+
rubygems_version: 2.4.5
|
155
143
|
signing_key:
|
156
|
-
specification_version:
|
144
|
+
specification_version: 4
|
157
145
|
summary: A Ruby interface to the BigQuery API.
|
158
146
|
test_files:
|
159
147
|
- test/helper.rb
|