google-cloud-spanner 2.6.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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: { optimizer_version: "1" }
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 incude:
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`
@@ -77,6 +77,9 @@ module Google
77
77
  # @private The Session object.
78
78
  attr_accessor :session
79
79
 
80
+ # @private Transaction tag for statistics collection.
81
+ attr_accessor :transaction_tag
82
+
80
83
  def initialize
81
84
  @commit = Commit.new
82
85
  @seqno = 0
@@ -113,6 +116,7 @@ module Google
113
116
  # | `BOOL` | `true`/`false` | |
114
117
  # | `INT64` | `Integer` | |
115
118
  # | `FLOAT64` | `Float` | |
119
+ # | `NUMERIC` | `BigDecimal` | |
116
120
  # | `STRING` | `String` | |
117
121
  # | `DATE` | `Date` | |
118
122
  # | `TIMESTAMP` | `Time`, `DateTime` | |
@@ -138,6 +142,7 @@ module Google
138
142
  # * `:BYTES`
139
143
  # * `:DATE`
140
144
  # * `:FLOAT64`
145
+ # * `:NUMERIC`
141
146
  # * `:INT64`
142
147
  # * `:STRING`
143
148
  # * `:TIMESTAMP`
@@ -155,6 +160,20 @@ module Google
155
160
  # * `:optimizer_version` (String) The version of optimizer to use.
156
161
  # Empty to use database default. "latest" to use the latest
157
162
  # available optimizer version.
163
+ # * `:optimizer_statistics_package` (String) Statistics package to
164
+ # use. Empty to use the database default.
165
+ # @param [Hash] request_options Common request options.
166
+ #
167
+ # * `:priority` (String) The relative priority for requests.
168
+ # The priority acts as a hint to the Cloud Spanner scheduler
169
+ # and does not guarantee priority or order of execution.
170
+ # Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
171
+ # `:PRIORITY_HIGH`. If priority not set then default is
172
+ # `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
173
+ # * `:tag` (String) A per-request tag which can be applied to
174
+ # queries or reads, used for statistics collection. Tag must be a
175
+ # valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
176
+ # and 64 characters in length.
158
177
  # @param [Hash] call_options A hash of values to specify the custom
159
178
  # call options, e.g., timeout, retries, etc. Call options are
160
179
  # optional. The following settings can be provided:
@@ -280,7 +299,10 @@ module Google
280
299
  #
281
300
  # db.transaction do |tx|
282
301
  # results = tx.execute_query \
283
- # "SELECT * FROM users", query_options: { optimizer_version: "1" }
302
+ # "SELECT * FROM users", query_options: {
303
+ # optimizer_version: "1",
304
+ # optimizer_statistics_package: "auto_20191128_14_47_22UTC"
305
+ # }
284
306
  #
285
307
  # results.rows.each do |row|
286
308
  # puts "User #{row[:id]} is #{row[:name]}"
@@ -312,15 +334,17 @@ module Google
312
334
  # end
313
335
  #
314
336
  def execute_query sql, params: nil, types: nil, query_options: nil,
315
- call_options: nil
337
+ request_options: nil, call_options: nil
316
338
  ensure_session!
317
339
 
318
340
  @seqno += 1
319
341
 
320
342
  params, types = Convert.to_input_params_and_types params, types
343
+ request_options = build_request_options request_options
321
344
  session.execute_query sql, params: params, types: types,
322
345
  transaction: tx_selector, seqno: @seqno,
323
346
  query_options: query_options,
347
+ request_options: request_options,
324
348
  call_options: call_options
325
349
  end
326
350
  alias execute execute_query
@@ -350,6 +374,7 @@ module Google
350
374
  # | `BOOL` | `true`/`false` | |
351
375
  # | `INT64` | `Integer` | |
352
376
  # | `FLOAT64` | `Float` | |
377
+ # | `NUMERIC` | `BigDecimal` | |
353
378
  # | `STRING` | `String` | |
354
379
  # | `DATE` | `Date` | |
355
380
  # | `TIMESTAMP` | `Time`, `DateTime` | |
@@ -376,6 +401,7 @@ module Google
376
401
  # * `:BYTES`
377
402
  # * `:DATE`
378
403
  # * `:FLOAT64`
404
+ # * `:NUMERIC`
379
405
  # * `:INT64`
380
406
  # * `:STRING`
381
407
  # * `:TIMESTAMP`
@@ -391,6 +417,20 @@ module Google
391
417
  # * `:optimizer_version` (String) The version of optimizer to use.
392
418
  # Empty to use database default. "latest" to use the latest
393
419
  # available optimizer version.
420
+ # * `:optimizer_statistics_package` (String) Statistics package to
421
+ # use. Empty to use the database default.
422
+ # @param [Hash] request_options Common request options.
423
+ #
424
+ # * `:priority` (String) The relative priority for requests.
425
+ # The priority acts as a hint to the Cloud Spanner scheduler
426
+ # and does not guarantee priority or order of execution.
427
+ # Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
428
+ # `:PRIORITY_HIGH`. If priority not set then default is
429
+ # `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
430
+ # * `:tag` (String) A per-request tag which can be applied to
431
+ # queries or reads, used for statistics collection. Tag must be a
432
+ # valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
433
+ # and 64 characters in length.
394
434
  # @param [Hash] call_options A hash of values to specify the custom
395
435
  # call options, e.g., timeout, retries, etc. Call options are
396
436
  # optional. The following settings can be provided:
@@ -441,7 +481,10 @@ module Google
441
481
  # db.transaction do |tx|
442
482
  # row_count = tx.execute_update(
443
483
  # "UPDATE users SET name = 'Charlie' WHERE id = 1",
444
- # query_options: { optimizer_version: "1" }
484
+ # query_options: {
485
+ # optimizer_version: "1",
486
+ # optimizer_statistics_package: "auto_20191128_14_47_22UTC"
487
+ # }
445
488
  # )
446
489
  # end
447
490
  #
@@ -468,9 +511,10 @@ module Google
468
511
  # end
469
512
  #
470
513
  def execute_update sql, params: nil, types: nil, query_options: nil,
471
- call_options: nil
514
+ request_options: nil, call_options: nil
472
515
  results = execute_query sql, params: params, types: types,
473
516
  query_options: query_options,
517
+ request_options: request_options,
474
518
  call_options: call_options
475
519
  # Stream all PartialResultSet to get ResultSetStats
476
520
  results.rows.to_a
@@ -485,6 +529,18 @@ module Google
485
529
  ##
486
530
  # Executes DML statements in a batch.
487
531
  #
532
+ # @param [Hash] request_options Common request options.
533
+ #
534
+ # * `:priority` (String) The relative priority for requests.
535
+ # The priority acts as a hint to the Cloud Spanner scheduler
536
+ # and does not guarantee priority or order of execution.
537
+ # Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
538
+ # `:PRIORITY_HIGH`. If priority not set then default is
539
+ # `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
540
+ # * `:tag` (String) A per-request tag which can be applied to
541
+ # queries or reads, used for statistics collection. Tag must be a
542
+ # valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
543
+ # and 64 characters in length.
488
544
  # @param [Hash] call_options A hash of values to specify the custom
489
545
  # call options, e.g., timeout, retries, etc. Call options are
490
546
  # optional. The following settings can be provided:
@@ -554,10 +610,13 @@ module Google
554
610
  # end
555
611
  # end
556
612
  #
557
- def batch_update call_options: nil, &block
613
+ def batch_update request_options: nil, call_options: nil, &block
558
614
  ensure_session!
559
615
  @seqno += 1
616
+
617
+ request_options = build_request_options request_options
560
618
  session.batch_update tx_selector, @seqno,
619
+ request_options: request_options,
561
620
  call_options: call_options, &block
562
621
  end
563
622
 
@@ -577,6 +636,18 @@ module Google
577
636
  # Optional.
578
637
  # @param [Integer] limit If greater than zero, no more than this number
579
638
  # of rows will be returned. The default is no limit.
639
+ # @param [Hash] request_options Common request options.
640
+ #
641
+ # * `:priority` (String) The relative priority for requests.
642
+ # The priority acts as a hint to the Cloud Spanner scheduler
643
+ # and does not guarantee priority or order of execution.
644
+ # Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
645
+ # `:PRIORITY_HIGH`. If priority not set then default is
646
+ # `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
647
+ # * `:tag` (String) A per-request tag which can be applied to
648
+ # queries or reads, used for statistics collection. Tag must be a
649
+ # valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
650
+ # and 64 characters in length.
580
651
  # @param [Hash] call_options A hash of values to specify the custom
581
652
  # call options, e.g., timeout, retries, etc. Call options are
582
653
  # optional. The following settings can be provided:
@@ -609,14 +680,15 @@ module Google
609
680
  # end
610
681
  #
611
682
  def read table, columns, keys: nil, index: nil, limit: nil,
612
- call_options: nil
683
+ request_options: nil, call_options: nil
613
684
  ensure_session!
614
685
 
615
686
  columns = Array(columns).map(&:to_s)
616
687
  keys = Convert.to_key_set keys
617
-
688
+ request_options = build_request_options request_options
618
689
  session.read table, columns, keys: keys, index: index, limit: limit,
619
690
  transaction: tx_selector,
691
+ request_options: request_options,
620
692
  call_options: call_options
621
693
  end
622
694
 
@@ -641,6 +713,7 @@ module Google
641
713
  # | `BOOL` | `true`/`false` | |
642
714
  # | `INT64` | `Integer` | |
643
715
  # | `FLOAT64` | `Float` | |
716
+ # | `NUMERIC` | `BigDecimal` | |
644
717
  # | `STRING` | `String` | |
645
718
  # | `DATE` | `Date` | |
646
719
  # | `TIMESTAMP` | `Time`, `DateTime` | |
@@ -687,6 +760,7 @@ module Google
687
760
  # | `BOOL` | `true`/`false` | |
688
761
  # | `INT64` | `Integer` | |
689
762
  # | `FLOAT64` | `Float` | |
763
+ # | `NUMERIC` | `BigDecimal` | |
690
764
  # | `STRING` | `String` | |
691
765
  # | `DATE` | `Date` | |
692
766
  # | `TIMESTAMP` | `Time`, `DateTime` | |
@@ -732,6 +806,7 @@ module Google
732
806
  # | `BOOL` | `true`/`false` | |
733
807
  # | `INT64` | `Integer` | |
734
808
  # | `FLOAT64` | `Float` | |
809
+ # | `NUMERIC` | `BigDecimal` | |
735
810
  # | `STRING` | `String` | |
736
811
  # | `DATE` | `Date` | |
737
812
  # | `TIMESTAMP` | `Time`, `DateTime` | |
@@ -779,6 +854,7 @@ module Google
779
854
  # | `BOOL` | `true`/`false` | |
780
855
  # | `INT64` | `Integer` | |
781
856
  # | `FLOAT64` | `Float` | |
857
+ # | `NUMERIC` | `BigDecimal` | |
782
858
  # | `STRING` | `String` | |
783
859
  # | `DATE` | `Date` | |
784
860
  # | `TIMESTAMP` | `Time`, `DateTime` | |
@@ -880,6 +956,7 @@ module Google
880
956
  # * `:BYTES`
881
957
  # * `:DATE`
882
958
  # * `:FLOAT64`
959
+ # * `:NUMERIC`
883
960
  # * `:INT64`
884
961
  # * `:STRING`
885
962
  # * `:TIMESTAMP`
@@ -1042,6 +1119,20 @@ module Google
1042
1119
  V1::TransactionSelector.new id: transaction_id
1043
1120
  end
1044
1121
 
1122
+ ##
1123
+ # @private Build request options. If transaction tag is set
1124
+ # then add into request options.
1125
+ def build_request_options options
1126
+ options = Convert.to_request_options options, tag_type: :request_tag
1127
+
1128
+ if transaction_tag
1129
+ options ||= {}
1130
+ options[:transaction_tag] = transaction_tag
1131
+ end
1132
+
1133
+ options
1134
+ end
1135
+
1045
1136
  ##
1046
1137
  # @private Raise an error unless an active connection to the service is
1047
1138
  # available.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Spanner
19
- VERSION = "2.6.0".freeze
19
+ VERSION = "2.9.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-spanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-31 00:00:00.000000000 Z
12
+ date: 2021-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
331
  - !ruby/object:Gem::Version
332
332
  version: '0'
333
333
  requirements: []
334
- rubygems_version: 3.2.13
334
+ rubygems_version: 3.2.17
335
335
  signing_key:
336
336
  specification_version: 4
337
337
  summary: API Client library for Google Cloud Spanner API