google-cloud-bigquery 0.20.2 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google-cloud-bigquery.rb +4 -15
- data/lib/google/cloud/bigquery.rb +73 -30
- data/lib/google/cloud/bigquery/data.rb +10 -15
- data/lib/google/cloud/bigquery/dataset.rb +32 -48
- data/lib/google/cloud/bigquery/dataset/access.rb +2 -3
- data/lib/google/cloud/bigquery/dataset/list.rb +10 -15
- data/lib/google/cloud/bigquery/job.rb +4 -6
- data/lib/google/cloud/bigquery/job/list.rb +10 -15
- data/lib/google/cloud/bigquery/project.rb +43 -60
- data/lib/google/cloud/bigquery/project/list.rb +10 -15
- data/lib/google/cloud/bigquery/query_data.rb +10 -15
- data/lib/google/cloud/bigquery/query_job.rb +2 -3
- data/lib/google/cloud/bigquery/schema.rb +4 -6
- data/lib/google/cloud/bigquery/service.rb +1 -1
- data/lib/google/cloud/bigquery/table.rb +41 -61
- data/lib/google/cloud/bigquery/table/list.rb +10 -15
- data/lib/google/cloud/bigquery/version.rb +1 -1
- data/lib/google/cloud/bigquery/view.rb +10 -15
- metadata +5 -5
@@ -26,10 +26,9 @@ module Google
|
|
26
26
|
# Control
|
27
27
|
#
|
28
28
|
# @example
|
29
|
-
# require "google/cloud"
|
29
|
+
# require "google/cloud/bigquery"
|
30
30
|
#
|
31
|
-
#
|
32
|
-
# bigquery = gcloud.bigquery
|
31
|
+
# bigquery = Google::Cloud::Bigquery.new
|
33
32
|
# dataset = bigquery.dataset "my_dataset"
|
34
33
|
#
|
35
34
|
# dataset.access do |access|
|
@@ -42,10 +42,9 @@ module Google
|
|
42
42
|
# @return [Boolean]
|
43
43
|
#
|
44
44
|
# @example
|
45
|
-
# require "google/cloud"
|
45
|
+
# require "google/cloud/bigquery"
|
46
46
|
#
|
47
|
-
#
|
48
|
-
# bigquery = gcloud.bigquery
|
47
|
+
# bigquery = Google::Cloud::Bigquery.new
|
49
48
|
#
|
50
49
|
# datasets = bigquery.datasets
|
51
50
|
# if datasets.next?
|
@@ -61,10 +60,9 @@ module Google
|
|
61
60
|
# @return [Dataset::List]
|
62
61
|
#
|
63
62
|
# @example
|
64
|
-
# require "google/cloud"
|
63
|
+
# require "google/cloud/bigquery"
|
65
64
|
#
|
66
|
-
#
|
67
|
-
# bigquery = gcloud.bigquery
|
65
|
+
# bigquery = Google::Cloud::Bigquery.new
|
68
66
|
#
|
69
67
|
# datasets = bigquery.datasets
|
70
68
|
# if datasets.next?
|
@@ -97,30 +95,27 @@ module Google
|
|
97
95
|
# @return [Enumerator]
|
98
96
|
#
|
99
97
|
# @example Iterating each result by passing a block:
|
100
|
-
# require "google/cloud"
|
98
|
+
# require "google/cloud/bigquery"
|
101
99
|
#
|
102
|
-
#
|
103
|
-
# bigquery = gcloud.bigquery
|
100
|
+
# bigquery = Google::Cloud::Bigquery.new
|
104
101
|
#
|
105
102
|
# bigquery.datasets.all do |dataset|
|
106
103
|
# puts dataset.name
|
107
104
|
# end
|
108
105
|
#
|
109
106
|
# @example Using the enumerator by not passing a block:
|
110
|
-
# require "google/cloud"
|
107
|
+
# require "google/cloud/bigquery"
|
111
108
|
#
|
112
|
-
#
|
113
|
-
# bigquery = gcloud.bigquery
|
109
|
+
# bigquery = Google::Cloud::Bigquery.new
|
114
110
|
#
|
115
111
|
# all_names = bigquery.datasets.all.map do |dataset|
|
116
112
|
# dataset.name
|
117
113
|
# end
|
118
114
|
#
|
119
115
|
# @example Limit the number of API calls made:
|
120
|
-
# require "google/cloud"
|
116
|
+
# require "google/cloud/bigquery"
|
121
117
|
#
|
122
|
-
#
|
123
|
-
# bigquery = gcloud.bigquery
|
118
|
+
# bigquery = Google::Cloud::Bigquery.new
|
124
119
|
#
|
125
120
|
# bigquery.datasets.all(request_limit: 10) do |dataset|
|
126
121
|
# puts dataset.name
|
@@ -40,10 +40,9 @@ module Google
|
|
40
40
|
# reference
|
41
41
|
#
|
42
42
|
# @example
|
43
|
-
# require "google/cloud"
|
43
|
+
# require "google/cloud/bigquery"
|
44
44
|
#
|
45
|
-
#
|
46
|
-
# bigquery = gcloud.bigquery
|
45
|
+
# bigquery = Google::Cloud::Bigquery.new
|
47
46
|
#
|
48
47
|
# q = "SELECT COUNT(word) as count FROM publicdata:samples.shakespeare"
|
49
48
|
# job = bigquery.query_job q
|
@@ -228,10 +227,9 @@ module Google
|
|
228
227
|
# The delay between refreshes will incrementally increase.
|
229
228
|
#
|
230
229
|
# @example
|
231
|
-
# require "google/cloud"
|
230
|
+
# require "google/cloud/bigquery"
|
232
231
|
#
|
233
|
-
#
|
234
|
-
# bigquery = gcloud.bigquery
|
232
|
+
# bigquery = Google::Cloud::Bigquery.new
|
235
233
|
# dataset = bigquery.dataset "my_dataset"
|
236
234
|
# table = dataset.table "my_table"
|
237
235
|
#
|
@@ -42,10 +42,9 @@ module Google
|
|
42
42
|
# @return [Boolean]
|
43
43
|
#
|
44
44
|
# @example
|
45
|
-
# require "google/cloud"
|
45
|
+
# require "google/cloud/bigquery"
|
46
46
|
#
|
47
|
-
#
|
48
|
-
# bigquery = gcloud.bigquery
|
47
|
+
# bigquery = Google::Cloud::Bigquery.new
|
49
48
|
#
|
50
49
|
# jobs = bigquery.jobs
|
51
50
|
# if jobs.next?
|
@@ -61,10 +60,9 @@ module Google
|
|
61
60
|
# @return [Job::List]
|
62
61
|
#
|
63
62
|
# @example
|
64
|
-
# require "google/cloud"
|
63
|
+
# require "google/cloud/bigquery"
|
65
64
|
#
|
66
|
-
#
|
67
|
-
# bigquery = gcloud.bigquery
|
65
|
+
# bigquery = Google::Cloud::Bigquery.new
|
68
66
|
#
|
69
67
|
# jobs = bigquery.jobs
|
70
68
|
# if jobs.next?
|
@@ -97,30 +95,27 @@ module Google
|
|
97
95
|
# @return [Enumerator]
|
98
96
|
#
|
99
97
|
# @example Iterating each job by passing a block:
|
100
|
-
# require "google/cloud"
|
98
|
+
# require "google/cloud/bigquery"
|
101
99
|
#
|
102
|
-
#
|
103
|
-
# bigquery = gcloud.bigquery
|
100
|
+
# bigquery = Google::Cloud::Bigquery.new
|
104
101
|
#
|
105
102
|
# bigquery.jobs.all do |job|
|
106
103
|
# puts job.state
|
107
104
|
# end
|
108
105
|
#
|
109
106
|
# @example Using the enumerator by not passing a block:
|
110
|
-
# require "google/cloud"
|
107
|
+
# require "google/cloud/bigquery"
|
111
108
|
#
|
112
|
-
#
|
113
|
-
# bigquery = gcloud.bigquery
|
109
|
+
# bigquery = Google::Cloud::Bigquery.new
|
114
110
|
#
|
115
111
|
# all_states = bigquery.jobs.all.map do |job|
|
116
112
|
# job.state
|
117
113
|
# end
|
118
114
|
#
|
119
115
|
# @example Limit the number of API calls made:
|
120
|
-
# require "google/cloud"
|
116
|
+
# require "google/cloud/bigquery"
|
121
117
|
#
|
122
|
-
#
|
123
|
-
# bigquery = gcloud.bigquery
|
118
|
+
# bigquery = Google::Cloud::Bigquery.new
|
124
119
|
#
|
125
120
|
# bigquery.jobs.all(request_limit: 10) do |job|
|
126
121
|
# puts job.state
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
-
require "google/cloud/core/
|
16
|
+
require "google/cloud/core/environment"
|
17
17
|
require "google/cloud/errors"
|
18
18
|
require "google/cloud/bigquery/service"
|
19
19
|
require "google/cloud/bigquery/credentials"
|
@@ -44,10 +44,9 @@ module Google
|
|
44
44
|
# Can only be present if the project was retrieved with {#projects}.
|
45
45
|
#
|
46
46
|
# @example
|
47
|
-
# require "google/cloud"
|
47
|
+
# require "google/cloud/bigquery"
|
48
48
|
#
|
49
|
-
#
|
50
|
-
# bigquery = gcloud.bigquery
|
49
|
+
# bigquery = Google::Cloud::Bigquery.new
|
51
50
|
# dataset = bigquery.dataset "my_dataset"
|
52
51
|
# table = dataset.table "my_table"
|
53
52
|
#
|
@@ -70,11 +69,12 @@ module Google
|
|
70
69
|
# The BigQuery project connected to.
|
71
70
|
#
|
72
71
|
# @example
|
73
|
-
# require "google/cloud"
|
72
|
+
# require "google/cloud/bigquery"
|
74
73
|
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
74
|
+
# bigquery = Google::Cloud::Bigquery.new(
|
75
|
+
# project: "my-todo-project",
|
76
|
+
# keyfile: "/path/to/keyfile.json"
|
77
|
+
# )
|
78
78
|
#
|
79
79
|
# bigquery.project #=> "my-todo-project"
|
80
80
|
#
|
@@ -88,7 +88,7 @@ module Google
|
|
88
88
|
ENV["BIGQUERY_PROJECT"] ||
|
89
89
|
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
90
90
|
ENV["GCLOUD_PROJECT"] ||
|
91
|
-
Google::Cloud::Core::
|
91
|
+
Google::Cloud::Core::Environment.project_id
|
92
92
|
end
|
93
93
|
|
94
94
|
##
|
@@ -139,10 +139,9 @@ module Google
|
|
139
139
|
# @return [Google::Cloud::Bigquery::QueryJob]
|
140
140
|
#
|
141
141
|
# @example
|
142
|
-
# require "google/cloud"
|
142
|
+
# require "google/cloud/bigquery"
|
143
143
|
#
|
144
|
-
#
|
145
|
-
# bigquery = gcloud.bigquery
|
144
|
+
# bigquery = Google::Cloud::Bigquery.new
|
146
145
|
#
|
147
146
|
# job = bigquery.query_job "SELECT name FROM " \
|
148
147
|
# "[my_proj:my_data.my_table]"
|
@@ -206,10 +205,9 @@ module Google
|
|
206
205
|
# @return [Google::Cloud::Bigquery::QueryData]
|
207
206
|
#
|
208
207
|
# @example
|
209
|
-
# require "google/cloud"
|
208
|
+
# require "google/cloud/bigquery"
|
210
209
|
#
|
211
|
-
#
|
212
|
-
# bigquery = gcloud.bigquery
|
210
|
+
# bigquery = Google::Cloud::Bigquery.new
|
213
211
|
#
|
214
212
|
# data = bigquery.query "SELECT name FROM [my_proj:my_data.my_table]"
|
215
213
|
# data.each do |row|
|
@@ -217,10 +215,9 @@ module Google
|
|
217
215
|
# end
|
218
216
|
#
|
219
217
|
# @example Retrieve all rows: (See {QueryData#all})
|
220
|
-
# require "google/cloud"
|
218
|
+
# require "google/cloud/bigquery"
|
221
219
|
#
|
222
|
-
#
|
223
|
-
# bigquery = gcloud.bigquery
|
220
|
+
# bigquery = Google::Cloud::Bigquery.new
|
224
221
|
#
|
225
222
|
# data = bigquery.query "SELECT name FROM [my_proj:my_data.my_table]"
|
226
223
|
# data.all do |row|
|
@@ -245,10 +242,9 @@ module Google
|
|
245
242
|
# dataset does not exist.
|
246
243
|
#
|
247
244
|
# @example
|
248
|
-
# require "google/cloud"
|
245
|
+
# require "google/cloud/bigquery"
|
249
246
|
#
|
250
|
-
#
|
251
|
-
# bigquery = gcloud.bigquery
|
247
|
+
# bigquery = Google::Cloud::Bigquery.new
|
252
248
|
#
|
253
249
|
# dataset = bigquery.dataset "my_dataset"
|
254
250
|
# puts dataset.name
|
@@ -282,37 +278,33 @@ module Google
|
|
282
278
|
# @return [Google::Cloud::Bigquery::Dataset]
|
283
279
|
#
|
284
280
|
# @example
|
285
|
-
# require "google/cloud"
|
281
|
+
# require "google/cloud/bigquery"
|
286
282
|
#
|
287
|
-
#
|
288
|
-
# bigquery = gcloud.bigquery
|
283
|
+
# bigquery = Google::Cloud::Bigquery.new
|
289
284
|
#
|
290
285
|
# dataset = bigquery.create_dataset "my_dataset"
|
291
286
|
#
|
292
287
|
# @example A name and description can be provided:
|
293
|
-
# require "google/cloud"
|
288
|
+
# require "google/cloud/bigquery"
|
294
289
|
#
|
295
|
-
#
|
296
|
-
# bigquery = gcloud.bigquery
|
290
|
+
# bigquery = Google::Cloud::Bigquery.new
|
297
291
|
#
|
298
292
|
# dataset = bigquery.create_dataset "my_dataset",
|
299
293
|
# name: "My Dataset",
|
300
294
|
# description: "This is my Dataset"
|
301
295
|
#
|
302
296
|
# @example Access rules can be provided with the `access` option:
|
303
|
-
# require "google/cloud"
|
297
|
+
# require "google/cloud/bigquery"
|
304
298
|
#
|
305
|
-
#
|
306
|
-
# bigquery = gcloud.bigquery
|
299
|
+
# bigquery = Google::Cloud::Bigquery.new
|
307
300
|
#
|
308
301
|
# dataset = bigquery.create_dataset "my_dataset",
|
309
302
|
# access: [{"role"=>"WRITER", "userByEmail"=>"writers@example.com"}]
|
310
303
|
#
|
311
304
|
# @example Or, configure access with a block: (See {Dataset::Access})
|
312
|
-
# require "google/cloud"
|
305
|
+
# require "google/cloud/bigquery"
|
313
306
|
#
|
314
|
-
#
|
315
|
-
# bigquery = gcloud.bigquery
|
307
|
+
# bigquery = Google::Cloud::Bigquery.new
|
316
308
|
#
|
317
309
|
# dataset = bigquery.create_dataset "my_dataset" do |access|
|
318
310
|
# access.add_writer_user "writers@example.com"
|
@@ -357,10 +349,9 @@ module Google
|
|
357
349
|
# {Google::Cloud::Bigquery::Dataset::List})
|
358
350
|
#
|
359
351
|
# @example
|
360
|
-
# require "google/cloud"
|
352
|
+
# require "google/cloud/bigquery"
|
361
353
|
#
|
362
|
-
#
|
363
|
-
# bigquery = gcloud.bigquery
|
354
|
+
# bigquery = Google::Cloud::Bigquery.new
|
364
355
|
#
|
365
356
|
# datasets = bigquery.datasets
|
366
357
|
# datasets.each do |dataset|
|
@@ -368,18 +359,16 @@ module Google
|
|
368
359
|
# end
|
369
360
|
#
|
370
361
|
# @example Retrieve hidden datasets with the `all` optional arg:
|
371
|
-
# require "google/cloud"
|
362
|
+
# require "google/cloud/bigquery"
|
372
363
|
#
|
373
|
-
#
|
374
|
-
# bigquery = gcloud.bigquery
|
364
|
+
# bigquery = Google::Cloud::Bigquery.new
|
375
365
|
#
|
376
366
|
# all_datasets = bigquery.datasets all: true
|
377
367
|
#
|
378
368
|
# @example Retrieve all datasets: (See {Dataset::List#all})
|
379
|
-
# require "google/cloud"
|
369
|
+
# require "google/cloud/bigquery"
|
380
370
|
#
|
381
|
-
#
|
382
|
-
# bigquery = gcloud.bigquery
|
371
|
+
# bigquery = Google::Cloud::Bigquery.new
|
383
372
|
#
|
384
373
|
# datasets = bigquery.datasets
|
385
374
|
# datasets.all do |dataset|
|
@@ -402,10 +391,9 @@ module Google
|
|
402
391
|
# does not exist.
|
403
392
|
#
|
404
393
|
# @example
|
405
|
-
# require "google/cloud"
|
394
|
+
# require "google/cloud/bigquery"
|
406
395
|
#
|
407
|
-
#
|
408
|
-
# bigquery = gcloud.bigquery
|
396
|
+
# bigquery = Google::Cloud::Bigquery.new
|
409
397
|
#
|
410
398
|
# job = bigquery.job "my_job"
|
411
399
|
#
|
@@ -437,10 +425,9 @@ module Google
|
|
437
425
|
# {Google::Cloud::Bigquery::Job::List})
|
438
426
|
#
|
439
427
|
# @example
|
440
|
-
# require "google/cloud"
|
428
|
+
# require "google/cloud/bigquery"
|
441
429
|
#
|
442
|
-
#
|
443
|
-
# bigquery = gcloud.bigquery
|
430
|
+
# bigquery = Google::Cloud::Bigquery.new
|
444
431
|
#
|
445
432
|
# jobs = bigquery.jobs
|
446
433
|
# jobs.each do |job|
|
@@ -448,10 +435,9 @@ module Google
|
|
448
435
|
# end
|
449
436
|
#
|
450
437
|
# @example Retrieve only running jobs using the `filter` optional arg:
|
451
|
-
# require "google/cloud"
|
438
|
+
# require "google/cloud/bigquery"
|
452
439
|
#
|
453
|
-
#
|
454
|
-
# bigquery = gcloud.bigquery
|
440
|
+
# bigquery = Google::Cloud::Bigquery.new
|
455
441
|
#
|
456
442
|
# running_jobs = bigquery.jobs filter: "running"
|
457
443
|
# running_jobs.each do |job|
|
@@ -459,10 +445,9 @@ module Google
|
|
459
445
|
# end
|
460
446
|
#
|
461
447
|
# @example Retrieve all jobs: (See {Job::List#all})
|
462
|
-
# require "google/cloud"
|
448
|
+
# require "google/cloud/bigquery"
|
463
449
|
#
|
464
|
-
#
|
465
|
-
# bigquery = gcloud.bigquery
|
450
|
+
# bigquery = Google::Cloud::Bigquery.new
|
466
451
|
#
|
467
452
|
# jobs = bigquery.jobs
|
468
453
|
# jobs.all do |job|
|
@@ -491,10 +476,9 @@ module Google
|
|
491
476
|
# {Google::Cloud::Bigquery::Project::List})
|
492
477
|
#
|
493
478
|
# @example
|
494
|
-
# require "google/cloud"
|
479
|
+
# require "google/cloud/bigquery"
|
495
480
|
#
|
496
|
-
#
|
497
|
-
# bigquery = gcloud.bigquery
|
481
|
+
# bigquery = Google::Cloud::Bigquery.new
|
498
482
|
#
|
499
483
|
# projects = bigquery.projects
|
500
484
|
# projects.each do |project|
|
@@ -505,10 +489,9 @@ module Google
|
|
505
489
|
# end
|
506
490
|
#
|
507
491
|
# @example Retrieve all projects: (See {Project::List#all})
|
508
|
-
# require "google/cloud"
|
492
|
+
# require "google/cloud/bigquery"
|
509
493
|
#
|
510
|
-
#
|
511
|
-
# bigquery = gcloud.bigquery
|
494
|
+
# bigquery = Google::Cloud::Bigquery.new
|
512
495
|
#
|
513
496
|
# projects = bigquery.projects
|
514
497
|
#
|
@@ -43,10 +43,9 @@ module Google
|
|
43
43
|
# @return [Boolean]
|
44
44
|
#
|
45
45
|
# @example
|
46
|
-
# require "google/cloud"
|
46
|
+
# require "google/cloud/bigquery"
|
47
47
|
#
|
48
|
-
#
|
49
|
-
# bigquery = gcloud.bigquery
|
48
|
+
# bigquery = Google::Cloud::Bigquery.new
|
50
49
|
#
|
51
50
|
# projects = bigquery.projects
|
52
51
|
# if projects.next?
|
@@ -62,10 +61,9 @@ module Google
|
|
62
61
|
# @return [Project::List]
|
63
62
|
#
|
64
63
|
# @example
|
65
|
-
# require "google/cloud"
|
64
|
+
# require "google/cloud/bigquery"
|
66
65
|
#
|
67
|
-
#
|
68
|
-
# bigquery = gcloud.bigquery
|
66
|
+
# bigquery = Google::Cloud::Bigquery.new
|
69
67
|
#
|
70
68
|
# projects = bigquery.projects
|
71
69
|
# if projects.next?
|
@@ -98,30 +96,27 @@ module Google
|
|
98
96
|
# @return [Enumerator]
|
99
97
|
#
|
100
98
|
# @example Iterating each result by passing a block:
|
101
|
-
# require "google/cloud"
|
99
|
+
# require "google/cloud/bigquery"
|
102
100
|
#
|
103
|
-
#
|
104
|
-
# bigquery = gcloud.bigquery
|
101
|
+
# bigquery = Google::Cloud::Bigquery.new
|
105
102
|
#
|
106
103
|
# bigquery.projects.all do |project|
|
107
104
|
# puts project.name
|
108
105
|
# end
|
109
106
|
#
|
110
107
|
# @example Using the enumerator by not passing a block:
|
111
|
-
# require "google/cloud"
|
108
|
+
# require "google/cloud/bigquery"
|
112
109
|
#
|
113
|
-
#
|
114
|
-
# bigquery = gcloud.bigquery
|
110
|
+
# bigquery = Google::Cloud::Bigquery.new
|
115
111
|
#
|
116
112
|
# all_project_ids = bigquery.projects.all.map do |project|
|
117
113
|
# project.name
|
118
114
|
# end
|
119
115
|
#
|
120
116
|
# @example Limit the number of API calls made:
|
121
|
-
# require "google/cloud"
|
117
|
+
# require "google/cloud/bigquery"
|
122
118
|
#
|
123
|
-
#
|
124
|
-
# bigquery = gcloud.bigquery
|
119
|
+
# bigquery = Google::Cloud::Bigquery.new
|
125
120
|
#
|
126
121
|
# bigquery.projects.all(request_limit: 10) do |project|
|
127
122
|
# puts project.name
|