google-cloud-spanner 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/OVERVIEW.md +1 -1
- data/lib/google-cloud-spanner.rb +2 -0
- data/lib/google/cloud/spanner/batch_snapshot.rb +9 -2
- data/lib/google/cloud/spanner/client.rb +272 -34
- data/lib/google/cloud/spanner/commit.rb +4 -0
- data/lib/google/cloud/spanner/database.rb +7 -0
- data/lib/google/cloud/spanner/fields.rb +2 -1
- data/lib/google/cloud/spanner/project.rb +4 -0
- data/lib/google/cloud/spanner/results.rb +7 -3
- data/lib/google/cloud/spanner/service.rb +12 -8
- data/lib/google/cloud/spanner/session.rb +33 -10
- data/lib/google/cloud/spanner/snapshot.rb +10 -2
- data/lib/google/cloud/spanner/transaction.rb +61 -6
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +3 -3
@@ -69,6 +69,7 @@ module Google
|
|
69
69
|
# | `BOOL` | `true`/`false` | |
|
70
70
|
# | `INT64` | `Integer` | |
|
71
71
|
# | `FLOAT64` | `Float` | |
|
72
|
+
# | `NUMERIC` | `BigDecimal` | |
|
72
73
|
# | `STRING` | `String` | |
|
73
74
|
# | `DATE` | `Date` | |
|
74
75
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -127,6 +128,7 @@ module Google
|
|
127
128
|
# | `BOOL` | `true`/`false` | |
|
128
129
|
# | `INT64` | `Integer` | |
|
129
130
|
# | `FLOAT64` | `Float` | |
|
131
|
+
# | `NUMERIC` | `BigDecimal` | |
|
130
132
|
# | `STRING` | `String` | |
|
131
133
|
# | `DATE` | `Date` | |
|
132
134
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -184,6 +186,7 @@ module Google
|
|
184
186
|
# | `BOOL` | `true`/`false` | |
|
185
187
|
# | `INT64` | `Integer` | |
|
186
188
|
# | `FLOAT64` | `Float` | |
|
189
|
+
# | `NUMERIC` | `BigDecimal` | |
|
187
190
|
# | `STRING` | `String` | |
|
188
191
|
# | `DATE` | `Date` | |
|
189
192
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -243,6 +246,7 @@ module Google
|
|
243
246
|
# | `BOOL` | `true`/`false` | |
|
244
247
|
# | `INT64` | `Integer` | |
|
245
248
|
# | `FLOAT64` | `Float` | |
|
249
|
+
# | `NUMERIC` | `BigDecimal` | |
|
246
250
|
# | `STRING` | `String` | |
|
247
251
|
# | `DATE` | `Date` | |
|
248
252
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -113,6 +113,13 @@ module Google
|
|
113
113
|
@grpc.state
|
114
114
|
end
|
115
115
|
|
116
|
+
##
|
117
|
+
# Time at which the database creation started.
|
118
|
+
# @return [Time]
|
119
|
+
def create_time
|
120
|
+
Convert.timestamp_to_time @grpc.create_time
|
121
|
+
end
|
122
|
+
|
116
123
|
# An encryption configuration describing the encryption type and key
|
117
124
|
# resources in Cloud KMS.
|
118
125
|
#
|
@@ -57,12 +57,13 @@ module Google
|
|
57
57
|
# Hash values must contain the type value. If a Hash is used the
|
58
58
|
# fields will be created using the same order as the Hash keys.
|
59
59
|
#
|
60
|
-
# Supported type values
|
60
|
+
# Supported type values include:
|
61
61
|
#
|
62
62
|
# * `:BOOL`
|
63
63
|
# * `:BYTES`
|
64
64
|
# * `:DATE`
|
65
65
|
# * `:FLOAT64`
|
66
|
+
# * `:NUMERIC`
|
66
67
|
# * `:INT64`
|
67
68
|
# * `:STRING`
|
68
69
|
# * `:TIMESTAMP`
|
@@ -490,6 +490,8 @@ module Google
|
|
490
490
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
491
491
|
# Empty to use database default. "latest" to use the latest
|
492
492
|
# available optimizer version.
|
493
|
+
# * `:optimizer_statistics_package` (String) Statistics package to
|
494
|
+
# use. Empty to use the database default.
|
493
495
|
#
|
494
496
|
# @return [Client] The newly created client.
|
495
497
|
#
|
@@ -554,6 +556,8 @@ module Google
|
|
554
556
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
555
557
|
# Empty to use database default. "latest" to use the latest
|
556
558
|
# available optimizer version.
|
559
|
+
# * `:optimizer_statistics_package` (String) Statistics package to
|
560
|
+
# use. Empty to use the database default.
|
557
561
|
#
|
558
562
|
# @return [Client] The newly created client.
|
559
563
|
#
|
@@ -319,11 +319,13 @@ module Google
|
|
319
319
|
def self.execute_query service, session_path, sql, params: nil,
|
320
320
|
types: nil, transaction: nil,
|
321
321
|
partition_token: nil, seqno: nil,
|
322
|
-
query_options: nil,
|
322
|
+
query_options: nil, request_options: nil,
|
323
|
+
call_options: nil
|
323
324
|
execute_query_options = {
|
324
325
|
transaction: transaction, params: params, types: types,
|
325
326
|
partition_token: partition_token, seqno: seqno,
|
326
|
-
query_options: query_options,
|
327
|
+
query_options: query_options, request_options: request_options,
|
328
|
+
call_options: call_options
|
327
329
|
}
|
328
330
|
enum = service.execute_streaming_sql session_path, sql,
|
329
331
|
**execute_query_options
|
@@ -338,11 +340,13 @@ module Google
|
|
338
340
|
# @private
|
339
341
|
def self.read service, session_path, table, columns, keys: nil,
|
340
342
|
index: nil, limit: nil, transaction: nil,
|
341
|
-
partition_token: nil,
|
343
|
+
partition_token: nil, request_options: nil,
|
344
|
+
call_options: nil
|
342
345
|
read_options = {
|
343
346
|
keys: keys, index: index, limit: limit,
|
344
347
|
transaction: transaction,
|
345
348
|
partition_token: partition_token,
|
349
|
+
request_options: request_options,
|
346
350
|
call_options: call_options
|
347
351
|
}
|
348
352
|
enum = service.streaming_read_table \
|
@@ -313,7 +313,8 @@ module Google
|
|
313
313
|
def execute_streaming_sql session_name, sql, transaction: nil,
|
314
314
|
params: nil, types: nil, resume_token: nil,
|
315
315
|
partition_token: nil, seqno: nil,
|
316
|
-
query_options: nil,
|
316
|
+
query_options: nil, request_options: nil,
|
317
|
+
call_options: nil
|
317
318
|
opts = default_options session_name: session_name,
|
318
319
|
call_options: call_options
|
319
320
|
request = {
|
@@ -325,13 +326,14 @@ module Google
|
|
325
326
|
resume_token: resume_token,
|
326
327
|
partition_token: partition_token,
|
327
328
|
seqno: seqno,
|
328
|
-
query_options: query_options
|
329
|
+
query_options: query_options,
|
330
|
+
request_options: request_options
|
329
331
|
}
|
330
332
|
service.execute_streaming_sql request, opts
|
331
333
|
end
|
332
334
|
|
333
335
|
def execute_batch_dml session_name, transaction, statements, seqno,
|
334
|
-
call_options: nil
|
336
|
+
request_options: nil, call_options: nil
|
335
337
|
opts = default_options session_name: session_name,
|
336
338
|
call_options: call_options
|
337
339
|
statements = statements.map(&:to_grpc)
|
@@ -339,7 +341,8 @@ module Google
|
|
339
341
|
session: session_name,
|
340
342
|
transaction: transaction,
|
341
343
|
statements: statements,
|
342
|
-
seqno: seqno
|
344
|
+
seqno: seqno,
|
345
|
+
request_options: request_options
|
343
346
|
}
|
344
347
|
results = service.execute_batch_dml request, opts
|
345
348
|
|
@@ -357,14 +360,14 @@ module Google
|
|
357
360
|
def streaming_read_table session_name, table_name, columns, keys: nil,
|
358
361
|
index: nil, transaction: nil, limit: nil,
|
359
362
|
resume_token: nil, partition_token: nil,
|
360
|
-
call_options: nil
|
363
|
+
request_options: nil, call_options: nil
|
361
364
|
opts = default_options session_name: session_name,
|
362
365
|
call_options: call_options
|
363
366
|
request = {
|
364
367
|
session: session_name, table: table_name, columns: columns,
|
365
368
|
key_set: keys, transaction: transaction, index: index,
|
366
369
|
limit: limit, resume_token: resume_token,
|
367
|
-
partition_token: partition_token
|
370
|
+
partition_token: partition_token, request_options: request_options
|
368
371
|
}
|
369
372
|
service.streaming_read request, opts
|
370
373
|
end
|
@@ -402,7 +405,7 @@ module Google
|
|
402
405
|
end
|
403
406
|
|
404
407
|
def commit session_name, mutations = [], transaction_id: nil,
|
405
|
-
commit_options: nil, call_options: nil
|
408
|
+
commit_options: nil, request_options: nil, call_options: nil
|
406
409
|
tx_opts = nil
|
407
410
|
if transaction_id.nil?
|
408
411
|
tx_opts = V1::TransactionOptions.new(
|
@@ -413,7 +416,8 @@ module Google
|
|
413
416
|
call_options: call_options
|
414
417
|
request = {
|
415
418
|
session: session_name, transaction_id: transaction_id,
|
416
|
-
single_use_transaction: tx_opts, mutations: mutations
|
419
|
+
single_use_transaction: tx_opts, mutations: mutations,
|
420
|
+
request_options: request_options
|
417
421
|
}
|
418
422
|
|
419
423
|
if commit_options
|
@@ -116,6 +116,7 @@ module Google
|
|
116
116
|
# | `BOOL` | `true`/`false` | |
|
117
117
|
# | `INT64` | `Integer` | |
|
118
118
|
# | `FLOAT64` | `Float` | |
|
119
|
+
# | `NUMERIC` | `BigDecimal` | |
|
119
120
|
# | `STRING` | `String` | |
|
120
121
|
# | `DATE` | `Date` | |
|
121
122
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -141,6 +142,7 @@ module Google
|
|
141
142
|
# * `:BYTES`
|
142
143
|
# * `:DATE`
|
143
144
|
# * `:FLOAT64`
|
145
|
+
# * `:NUMERIC`
|
144
146
|
# * `:INT64`
|
145
147
|
# * `:STRING`
|
146
148
|
# * `:TIMESTAMP`
|
@@ -163,6 +165,8 @@ module Google
|
|
163
165
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
164
166
|
# Empty to use database default. "latest" to use the latest
|
165
167
|
# available optimizer version.
|
168
|
+
# * `:optimizer_statistics_package` (String) Statistics package to
|
169
|
+
# use. Empty to use the database default.
|
166
170
|
# @param [Hash] call_options A hash of values to specify the custom
|
167
171
|
# call options, e.g., timeout, retries, etc. Call options are
|
168
172
|
# optional. The following settings can be provided:
|
@@ -283,7 +287,10 @@ module Google
|
|
283
287
|
# db = spanner.client "my-instance", "my-database"
|
284
288
|
#
|
285
289
|
# results = db.execute_query \
|
286
|
-
# "SELECT * FROM users", query_options: {
|
290
|
+
# "SELECT * FROM users", query_options: {
|
291
|
+
# optimizer_version: "1",
|
292
|
+
# optimizer_statistics_package: "auto_20191128_14_47_22UTC"
|
293
|
+
# }
|
287
294
|
#
|
288
295
|
# results.rows.each do |row|
|
289
296
|
# puts "User #{row[:id]} is #{row[:name]}"
|
@@ -314,7 +321,7 @@ module Google
|
|
314
321
|
#
|
315
322
|
def execute_query sql, params: nil, types: nil, transaction: nil,
|
316
323
|
partition_token: nil, seqno: nil, query_options: nil,
|
317
|
-
call_options: nil
|
324
|
+
request_options: nil, call_options: nil
|
318
325
|
ensure_service!
|
319
326
|
if query_options.nil?
|
320
327
|
query_options = @query_options
|
@@ -328,6 +335,7 @@ module Google
|
|
328
335
|
partition_token: partition_token,
|
329
336
|
seqno: seqno,
|
330
337
|
query_options: query_options,
|
338
|
+
request_options: request_options,
|
331
339
|
call_options: call_options
|
332
340
|
@last_updated_at = Time.now
|
333
341
|
results
|
@@ -369,7 +377,8 @@ module Google
|
|
369
377
|
# @return [Array<Integer>] A list with the exact number of rows that
|
370
378
|
# were modified for each DML statement.
|
371
379
|
#
|
372
|
-
def batch_update transaction, seqno,
|
380
|
+
def batch_update transaction, seqno, request_options: nil,
|
381
|
+
call_options: nil
|
373
382
|
ensure_service!
|
374
383
|
|
375
384
|
raise ArgumentError, "block is required" unless block_given?
|
@@ -379,6 +388,7 @@ module Google
|
|
379
388
|
|
380
389
|
results = service.execute_batch_dml path, transaction,
|
381
390
|
batch.statements, seqno,
|
391
|
+
request_options: request_options,
|
382
392
|
call_options: call_options
|
383
393
|
@last_updated_at = Time.now
|
384
394
|
results
|
@@ -434,13 +444,15 @@ module Google
|
|
434
444
|
# end
|
435
445
|
#
|
436
446
|
def read table, columns, keys: nil, index: nil, limit: nil,
|
437
|
-
transaction: nil, partition_token: nil,
|
447
|
+
transaction: nil, partition_token: nil, request_options: nil,
|
448
|
+
call_options: nil
|
438
449
|
ensure_service!
|
439
450
|
|
440
451
|
results = Results.read service, path, table, columns,
|
441
452
|
keys: keys, index: index, limit: limit,
|
442
453
|
transaction: transaction,
|
443
454
|
partition_token: partition_token,
|
455
|
+
request_options: request_options,
|
444
456
|
call_options: call_options
|
445
457
|
@last_updated_at = Time.now
|
446
458
|
results
|
@@ -542,13 +554,15 @@ module Google
|
|
542
554
|
# puts commit_resp.timestamp
|
543
555
|
# puts commit_resp.stats.mutation_count
|
544
556
|
#
|
545
|
-
def commit transaction_id: nil, commit_options: nil,
|
557
|
+
def commit transaction_id: nil, commit_options: nil,
|
558
|
+
request_options: nil, call_options: nil
|
546
559
|
ensure_service!
|
547
560
|
commit = Commit.new
|
548
561
|
yield commit
|
549
562
|
commit_resp = service.commit path, commit.mutations,
|
550
563
|
transaction_id: transaction_id,
|
551
564
|
commit_options: commit_options,
|
565
|
+
request_options: request_options,
|
552
566
|
call_options: call_options
|
553
567
|
@last_updated_at = Time.now
|
554
568
|
resp = CommitResponse.from_grpc commit_resp
|
@@ -573,6 +587,7 @@ module Google
|
|
573
587
|
# | `BOOL` | `true`/`false` | |
|
574
588
|
# | `INT64` | `Integer` | |
|
575
589
|
# | `FLOAT64` | `Float` | |
|
590
|
+
# | `NUMERIC` | `BigDecimal` | |
|
576
591
|
# | `STRING` | `String` | |
|
577
592
|
# | `DATE` | `Date` | |
|
578
593
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -633,10 +648,11 @@ module Google
|
|
633
648
|
# puts commit_resp.stats.mutation_count
|
634
649
|
#
|
635
650
|
def upsert table, *rows, transaction_id: nil, commit_options: nil,
|
636
|
-
call_options: nil
|
651
|
+
request_options: nil, call_options: nil
|
637
652
|
opts = {
|
638
653
|
transaction_id: transaction_id,
|
639
654
|
commit_options: commit_options,
|
655
|
+
request_options: request_options,
|
640
656
|
call_options: call_options
|
641
657
|
}
|
642
658
|
commit(**opts) do |c|
|
@@ -662,6 +678,7 @@ module Google
|
|
662
678
|
# | `BOOL` | `true`/`false` | |
|
663
679
|
# | `INT64` | `Integer` | |
|
664
680
|
# | `FLOAT64` | `Float` | |
|
681
|
+
# | `NUMERIC` | `BigDecimal` | |
|
665
682
|
# | `STRING` | `String` | |
|
666
683
|
# | `DATE` | `Date` | |
|
667
684
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -722,10 +739,11 @@ module Google
|
|
722
739
|
# puts commit_resp.stats.mutation_count
|
723
740
|
#
|
724
741
|
def insert table, *rows, transaction_id: nil, commit_options: nil,
|
725
|
-
call_options: nil
|
742
|
+
request_options: nil, call_options: nil
|
726
743
|
opts = {
|
727
744
|
transaction_id: transaction_id,
|
728
745
|
commit_options: commit_options,
|
746
|
+
request_options: request_options,
|
729
747
|
call_options: call_options
|
730
748
|
}
|
731
749
|
commit(**opts) do |c|
|
@@ -750,6 +768,7 @@ module Google
|
|
750
768
|
# | `BOOL` | `true`/`false` | |
|
751
769
|
# | `INT64` | `Integer` | |
|
752
770
|
# | `FLOAT64` | `Float` | |
|
771
|
+
# | `NUMERIC` | `BigDecimal` | |
|
753
772
|
# | `STRING` | `String` | |
|
754
773
|
# | `DATE` | `Date` | |
|
755
774
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -810,10 +829,11 @@ module Google
|
|
810
829
|
# puts commit_resp.stats.mutation_count
|
811
830
|
#
|
812
831
|
def update table, *rows, transaction_id: nil, commit_options: nil,
|
813
|
-
call_options: nil
|
832
|
+
request_options: nil, call_options: nil
|
814
833
|
opts = {
|
815
834
|
transaction_id: transaction_id,
|
816
835
|
commit_options: commit_options,
|
836
|
+
request_options: request_options,
|
817
837
|
call_options: call_options
|
818
838
|
}
|
819
839
|
commit(**opts) do |c|
|
@@ -840,6 +860,7 @@ module Google
|
|
840
860
|
# | `BOOL` | `true`/`false` | |
|
841
861
|
# | `INT64` | `Integer` | |
|
842
862
|
# | `FLOAT64` | `Float` | |
|
863
|
+
# | `NUMERIC` | `BigDecimal` | |
|
843
864
|
# | `STRING` | `String` | |
|
844
865
|
# | `DATE` | `Date` | |
|
845
866
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -900,10 +921,11 @@ module Google
|
|
900
921
|
# puts commit_resp.stats.mutation_count
|
901
922
|
#
|
902
923
|
def replace table, *rows, transaction_id: nil, commit_options: nil,
|
903
|
-
call_options: nil
|
924
|
+
request_options: nil, call_options: nil
|
904
925
|
opts = {
|
905
926
|
transaction_id: transaction_id,
|
906
927
|
commit_options: commit_options,
|
928
|
+
request_options: request_options,
|
907
929
|
call_options: call_options
|
908
930
|
}
|
909
931
|
commit(**opts) do |c|
|
@@ -968,10 +990,11 @@ module Google
|
|
968
990
|
# puts commit_resp.stats.mutation_count
|
969
991
|
#
|
970
992
|
def delete table, keys = [], transaction_id: nil, commit_options: nil,
|
971
|
-
call_options: nil
|
993
|
+
request_options: nil, call_options: nil
|
972
994
|
opts = {
|
973
995
|
transaction_id: transaction_id,
|
974
996
|
commit_options: commit_options,
|
997
|
+
request_options: request_options,
|
975
998
|
call_options: call_options
|
976
999
|
}
|
977
1000
|
commit(**opts) do |c|
|
@@ -83,6 +83,7 @@ module Google
|
|
83
83
|
# | `BOOL` | `true`/`false` | |
|
84
84
|
# | `INT64` | `Integer` | |
|
85
85
|
# | `FLOAT64` | `Float` | |
|
86
|
+
# | `NUMERIC` | `BigDecimal` | |
|
86
87
|
# | `STRING` | `String` | |
|
87
88
|
# | `DATE` | `Date` | |
|
88
89
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -108,6 +109,7 @@ module Google
|
|
108
109
|
# * `:BYTES`
|
109
110
|
# * `:DATE`
|
110
111
|
# * `:FLOAT64`
|
112
|
+
# * `:NUMERIC`
|
111
113
|
# * `:INT64`
|
112
114
|
# * `:STRING`
|
113
115
|
# * `:TIMESTAMP`
|
@@ -125,6 +127,8 @@ module Google
|
|
125
127
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
126
128
|
# Empty to use database default. "latest" to use the latest
|
127
129
|
# available optimizer version.
|
130
|
+
# * `:optimizer_statistics_package` (String) Statistics package to
|
131
|
+
# use. Empty to use the database default.
|
128
132
|
# @param [Hash] call_options A hash of values to specify the custom
|
129
133
|
# call options, e.g., timeout, retries, etc. Call options are
|
130
134
|
# optional. The following settings can be provided:
|
@@ -249,7 +253,10 @@ module Google
|
|
249
253
|
#
|
250
254
|
# db.snapshot do |snp|
|
251
255
|
# results = snp.execute_query \
|
252
|
-
# "SELECT * FROM users", query_options: {
|
256
|
+
# "SELECT * FROM users", query_options: {
|
257
|
+
# optimizer_version: "1",
|
258
|
+
# optimizer_statistics_package: "auto_20191128_14_47_22UTC"
|
259
|
+
# }
|
253
260
|
#
|
254
261
|
# results.rows.each do |row|
|
255
262
|
# puts "User #{row[:id]} is #{row[:name]}"
|
@@ -373,12 +380,13 @@ module Google
|
|
373
380
|
# Hash values must contain the type value. If a Hash is used the
|
374
381
|
# fields will be created using the same order as the Hash keys.
|
375
382
|
#
|
376
|
-
# Supported type values
|
383
|
+
# Supported type values include:
|
377
384
|
#
|
378
385
|
# * `:BOOL`
|
379
386
|
# * `:BYTES`
|
380
387
|
# * `:DATE`
|
381
388
|
# * `:FLOAT64`
|
389
|
+
# * `:NUMERIC`
|
382
390
|
# * `:INT64`
|
383
391
|
# * `:STRING`
|
384
392
|
# * `:TIMESTAMP`
|
@@ -113,6 +113,7 @@ module Google
|
|
113
113
|
# | `BOOL` | `true`/`false` | |
|
114
114
|
# | `INT64` | `Integer` | |
|
115
115
|
# | `FLOAT64` | `Float` | |
|
116
|
+
# | `NUMERIC` | `BigDecimal` | |
|
116
117
|
# | `STRING` | `String` | |
|
117
118
|
# | `DATE` | `Date` | |
|
118
119
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -138,6 +139,7 @@ module Google
|
|
138
139
|
# * `:BYTES`
|
139
140
|
# * `:DATE`
|
140
141
|
# * `:FLOAT64`
|
142
|
+
# * `:NUMERIC`
|
141
143
|
# * `:INT64`
|
142
144
|
# * `:STRING`
|
143
145
|
# * `:TIMESTAMP`
|
@@ -155,6 +157,16 @@ module Google
|
|
155
157
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
156
158
|
# Empty to use database default. "latest" to use the latest
|
157
159
|
# available optimizer version.
|
160
|
+
# * `:optimizer_statistics_package` (String) Statistics package to
|
161
|
+
# use. Empty to use the database default.
|
162
|
+
# @param [Hash] request_options Common request options.
|
163
|
+
#
|
164
|
+
# * `:priority` (String) The relative priority for requests.
|
165
|
+
# The priority acts as a hint to the Cloud Spanner scheduler
|
166
|
+
# and does not guarantee priority or order of execution.
|
167
|
+
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
168
|
+
# `:PRIORITY_HIGH`. If priority not set then default is
|
169
|
+
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
158
170
|
# @param [Hash] call_options A hash of values to specify the custom
|
159
171
|
# call options, e.g., timeout, retries, etc. Call options are
|
160
172
|
# optional. The following settings can be provided:
|
@@ -280,7 +292,10 @@ module Google
|
|
280
292
|
#
|
281
293
|
# db.transaction do |tx|
|
282
294
|
# results = tx.execute_query \
|
283
|
-
# "SELECT * FROM users", query_options: {
|
295
|
+
# "SELECT * FROM users", query_options: {
|
296
|
+
# optimizer_version: "1",
|
297
|
+
# optimizer_statistics_package: "auto_20191128_14_47_22UTC"
|
298
|
+
# }
|
284
299
|
#
|
285
300
|
# results.rows.each do |row|
|
286
301
|
# puts "User #{row[:id]} is #{row[:name]}"
|
@@ -312,7 +327,7 @@ module Google
|
|
312
327
|
# end
|
313
328
|
#
|
314
329
|
def execute_query sql, params: nil, types: nil, query_options: nil,
|
315
|
-
call_options: nil
|
330
|
+
request_options: nil, call_options: nil
|
316
331
|
ensure_session!
|
317
332
|
|
318
333
|
@seqno += 1
|
@@ -321,6 +336,7 @@ module Google
|
|
321
336
|
session.execute_query sql, params: params, types: types,
|
322
337
|
transaction: tx_selector, seqno: @seqno,
|
323
338
|
query_options: query_options,
|
339
|
+
request_options: request_options,
|
324
340
|
call_options: call_options
|
325
341
|
end
|
326
342
|
alias execute execute_query
|
@@ -350,6 +366,7 @@ module Google
|
|
350
366
|
# | `BOOL` | `true`/`false` | |
|
351
367
|
# | `INT64` | `Integer` | |
|
352
368
|
# | `FLOAT64` | `Float` | |
|
369
|
+
# | `NUMERIC` | `BigDecimal` | |
|
353
370
|
# | `STRING` | `String` | |
|
354
371
|
# | `DATE` | `Date` | |
|
355
372
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -376,6 +393,7 @@ module Google
|
|
376
393
|
# * `:BYTES`
|
377
394
|
# * `:DATE`
|
378
395
|
# * `:FLOAT64`
|
396
|
+
# * `:NUMERIC`
|
379
397
|
# * `:INT64`
|
380
398
|
# * `:STRING`
|
381
399
|
# * `:TIMESTAMP`
|
@@ -391,6 +409,16 @@ module Google
|
|
391
409
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
392
410
|
# Empty to use database default. "latest" to use the latest
|
393
411
|
# available optimizer version.
|
412
|
+
# * `:optimizer_statistics_package` (String) Statistics package to
|
413
|
+
# use. Empty to use the database default.
|
414
|
+
# @param [Hash] request_options Common request options.
|
415
|
+
#
|
416
|
+
# * `:priority` (String) The relative priority for requests.
|
417
|
+
# The priority acts as a hint to the Cloud Spanner scheduler
|
418
|
+
# and does not guarantee priority or order of execution.
|
419
|
+
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
420
|
+
# `:PRIORITY_HIGH`. If priority not set then default is
|
421
|
+
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
394
422
|
# @param [Hash] call_options A hash of values to specify the custom
|
395
423
|
# call options, e.g., timeout, retries, etc. Call options are
|
396
424
|
# optional. The following settings can be provided:
|
@@ -441,7 +469,10 @@ module Google
|
|
441
469
|
# db.transaction do |tx|
|
442
470
|
# row_count = tx.execute_update(
|
443
471
|
# "UPDATE users SET name = 'Charlie' WHERE id = 1",
|
444
|
-
# query_options: {
|
472
|
+
# query_options: {
|
473
|
+
# optimizer_version: "1",
|
474
|
+
# optimizer_statistics_package: "auto_20191128_14_47_22UTC"
|
475
|
+
# }
|
445
476
|
# )
|
446
477
|
# end
|
447
478
|
#
|
@@ -468,9 +499,10 @@ module Google
|
|
468
499
|
# end
|
469
500
|
#
|
470
501
|
def execute_update sql, params: nil, types: nil, query_options: nil,
|
471
|
-
call_options: nil
|
502
|
+
request_options: nil, call_options: nil
|
472
503
|
results = execute_query sql, params: params, types: types,
|
473
504
|
query_options: query_options,
|
505
|
+
request_options: request_options,
|
474
506
|
call_options: call_options
|
475
507
|
# Stream all PartialResultSet to get ResultSetStats
|
476
508
|
results.rows.to_a
|
@@ -485,6 +517,14 @@ module Google
|
|
485
517
|
##
|
486
518
|
# Executes DML statements in a batch.
|
487
519
|
#
|
520
|
+
# @param [Hash] request_options Common request options.
|
521
|
+
#
|
522
|
+
# * `:priority` (String) The relative priority for requests.
|
523
|
+
# The priority acts as a hint to the Cloud Spanner scheduler
|
524
|
+
# and does not guarantee priority or order of execution.
|
525
|
+
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
526
|
+
# `:PRIORITY_HIGH`. If priority not set then default is
|
527
|
+
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
488
528
|
# @param [Hash] call_options A hash of values to specify the custom
|
489
529
|
# call options, e.g., timeout, retries, etc. Call options are
|
490
530
|
# optional. The following settings can be provided:
|
@@ -554,10 +594,11 @@ module Google
|
|
554
594
|
# end
|
555
595
|
# end
|
556
596
|
#
|
557
|
-
def batch_update call_options: nil, &block
|
597
|
+
def batch_update request_options: nil, call_options: nil, &block
|
558
598
|
ensure_session!
|
559
599
|
@seqno += 1
|
560
600
|
session.batch_update tx_selector, @seqno,
|
601
|
+
request_options: request_options,
|
561
602
|
call_options: call_options, &block
|
562
603
|
end
|
563
604
|
|
@@ -577,6 +618,14 @@ module Google
|
|
577
618
|
# Optional.
|
578
619
|
# @param [Integer] limit If greater than zero, no more than this number
|
579
620
|
# of rows will be returned. The default is no limit.
|
621
|
+
# @param [Hash] request_options Common request options.
|
622
|
+
#
|
623
|
+
# * `:priority` (String) The relative priority for requests.
|
624
|
+
# The priority acts as a hint to the Cloud Spanner scheduler
|
625
|
+
# and does not guarantee priority or order of execution.
|
626
|
+
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
627
|
+
# `:PRIORITY_HIGH`. If priority not set then default is
|
628
|
+
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
580
629
|
# @param [Hash] call_options A hash of values to specify the custom
|
581
630
|
# call options, e.g., timeout, retries, etc. Call options are
|
582
631
|
# optional. The following settings can be provided:
|
@@ -609,7 +658,7 @@ module Google
|
|
609
658
|
# end
|
610
659
|
#
|
611
660
|
def read table, columns, keys: nil, index: nil, limit: nil,
|
612
|
-
call_options: nil
|
661
|
+
request_options: nil, call_options: nil
|
613
662
|
ensure_session!
|
614
663
|
|
615
664
|
columns = Array(columns).map(&:to_s)
|
@@ -617,6 +666,7 @@ module Google
|
|
617
666
|
|
618
667
|
session.read table, columns, keys: keys, index: index, limit: limit,
|
619
668
|
transaction: tx_selector,
|
669
|
+
request_options: request_options,
|
620
670
|
call_options: call_options
|
621
671
|
end
|
622
672
|
|
@@ -641,6 +691,7 @@ module Google
|
|
641
691
|
# | `BOOL` | `true`/`false` | |
|
642
692
|
# | `INT64` | `Integer` | |
|
643
693
|
# | `FLOAT64` | `Float` | |
|
694
|
+
# | `NUMERIC` | `BigDecimal` | |
|
644
695
|
# | `STRING` | `String` | |
|
645
696
|
# | `DATE` | `Date` | |
|
646
697
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -687,6 +738,7 @@ module Google
|
|
687
738
|
# | `BOOL` | `true`/`false` | |
|
688
739
|
# | `INT64` | `Integer` | |
|
689
740
|
# | `FLOAT64` | `Float` | |
|
741
|
+
# | `NUMERIC` | `BigDecimal` | |
|
690
742
|
# | `STRING` | `String` | |
|
691
743
|
# | `DATE` | `Date` | |
|
692
744
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -732,6 +784,7 @@ module Google
|
|
732
784
|
# | `BOOL` | `true`/`false` | |
|
733
785
|
# | `INT64` | `Integer` | |
|
734
786
|
# | `FLOAT64` | `Float` | |
|
787
|
+
# | `NUMERIC` | `BigDecimal` | |
|
735
788
|
# | `STRING` | `String` | |
|
736
789
|
# | `DATE` | `Date` | |
|
737
790
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -779,6 +832,7 @@ module Google
|
|
779
832
|
# | `BOOL` | `true`/`false` | |
|
780
833
|
# | `INT64` | `Integer` | |
|
781
834
|
# | `FLOAT64` | `Float` | |
|
835
|
+
# | `NUMERIC` | `BigDecimal` | |
|
782
836
|
# | `STRING` | `String` | |
|
783
837
|
# | `DATE` | `Date` | |
|
784
838
|
# | `TIMESTAMP` | `Time`, `DateTime` | |
|
@@ -880,6 +934,7 @@ module Google
|
|
880
934
|
# * `:BYTES`
|
881
935
|
# * `:DATE`
|
882
936
|
# * `:FLOAT64`
|
937
|
+
# * `:NUMERIC`
|
883
938
|
# * `:INT64`
|
884
939
|
# * `:STRING`
|
885
940
|
# * `:TIMESTAMP`
|