google-cloud-spanner 1.14.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +51 -0
  4. data/CONTRIBUTING.md +5 -5
  5. data/TROUBLESHOOTING.md +0 -6
  6. data/lib/google-cloud-spanner.rb +23 -13
  7. data/lib/google/cloud/spanner.rb +8 -9
  8. data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
  9. data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
  10. data/lib/google/cloud/spanner/backup.rb +315 -0
  11. data/lib/google/cloud/spanner/backup/job.rb +274 -0
  12. data/lib/google/cloud/spanner/backup/job/list.rb +177 -0
  13. data/lib/google/cloud/spanner/backup/list.rb +169 -0
  14. data/lib/google/cloud/spanner/backup/restore/job.rb +246 -0
  15. data/lib/google/cloud/spanner/batch_client.rb +7 -5
  16. data/lib/google/cloud/spanner/batch_snapshot.rb +49 -16
  17. data/lib/google/cloud/spanner/batch_update.rb +1 -1
  18. data/lib/google/cloud/spanner/client.rb +65 -16
  19. data/lib/google/cloud/spanner/commit.rb +14 -14
  20. data/lib/google/cloud/spanner/convert.rb +7 -7
  21. data/lib/google/cloud/spanner/credentials.rb +2 -2
  22. data/lib/google/cloud/spanner/data.rb +2 -2
  23. data/lib/google/cloud/spanner/database.rb +275 -15
  24. data/lib/google/cloud/spanner/database/backup_info.rb +105 -0
  25. data/lib/google/cloud/spanner/database/job.rb +5 -2
  26. data/lib/google/cloud/spanner/database/job/list.rb +177 -0
  27. data/lib/google/cloud/spanner/database/list.rb +1 -1
  28. data/lib/google/cloud/spanner/database/restore_info.rb +63 -0
  29. data/lib/google/cloud/spanner/fields.rb +8 -8
  30. data/lib/google/cloud/spanner/instance.rb +401 -8
  31. data/lib/google/cloud/spanner/instance/config.rb +1 -1
  32. data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
  33. data/lib/google/cloud/spanner/instance/job.rb +2 -2
  34. data/lib/google/cloud/spanner/instance/list.rb +1 -1
  35. data/lib/google/cloud/spanner/partition.rb +4 -4
  36. data/lib/google/cloud/spanner/policy.rb +2 -2
  37. data/lib/google/cloud/spanner/project.rb +31 -6
  38. data/lib/google/cloud/spanner/results.rb +4 -2
  39. data/lib/google/cloud/spanner/service.rb +231 -240
  40. data/lib/google/cloud/spanner/session.rb +46 -15
  41. data/lib/google/cloud/spanner/snapshot.rb +28 -5
  42. data/lib/google/cloud/spanner/transaction.rb +51 -7
  43. data/lib/google/cloud/spanner/version.rb +1 -1
  44. metadata +28 -104
  45. data/lib/google/cloud/spanner/admin/database.rb +0 -148
  46. data/lib/google/cloud/spanner/admin/database/v1.rb +0 -146
  47. data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
  48. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -791
  49. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -71
  50. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  51. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
  52. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
  53. data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
  54. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
  55. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
  56. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
  57. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -201
  58. data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
  59. data/lib/google/cloud/spanner/admin/instance.rb +0 -164
  60. data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
  61. data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
  62. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  63. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
  64. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
  65. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
  66. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
  67. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
  68. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
  69. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
  70. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -341
  71. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
  72. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -972
  73. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
  74. data/lib/google/cloud/spanner/v1.rb +0 -16
  75. data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
  76. data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
  77. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
  78. data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
  79. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
  80. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
  81. data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
  82. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
  83. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -88
  84. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
  85. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
  86. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -581
  87. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
  88. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
  89. data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1509
  90. data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
  91. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -88
  92. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -99
  93. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
  94. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -182
  95. data/lib/google/spanner/v1/keys_pb.rb +0 -34
  96. data/lib/google/spanner/v1/mutation_pb.rb +0 -39
  97. data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
  98. data/lib/google/spanner/v1/result_set_pb.rb +0 -48
  99. data/lib/google/spanner/v1/spanner_pb.rb +0 -174
  100. data/lib/google/spanner/v1/spanner_services_pb.rb +0 -188
  101. data/lib/google/spanner/v1/transaction_pb.rb +0 -56
  102. data/lib/google/spanner/v1/type_pb.rb +0 -44
@@ -166,6 +166,13 @@ module Google
166
166
  # partitions to return. For example, this may be set to the number of
167
167
  # workers available. This is only a hint and may provide different
168
168
  # results based on the request.
169
+ # @param [Hash] query_options A hash of values to specify the custom
170
+ # query options for executing SQL query. Query options are optional.
171
+ # The following settings can be provided:
172
+ #
173
+ # * `:optimizer_version` (String) The version of optimizer to use.
174
+ # Empty to use database default. "latest" to use the latest
175
+ # available optimizer version.
169
176
  #
170
177
  # @return [Array<Google::Cloud::Spanner::Partition>] The partitions
171
178
  # created by the query partition.
@@ -188,7 +195,8 @@ module Google
188
195
  # batch_snapshot.close
189
196
  #
190
197
  def partition_query sql, params: nil, types: nil,
191
- partition_size_bytes: nil, max_partitions: nil
198
+ partition_size_bytes: nil, max_partitions: nil,
199
+ query_options: nil
192
200
  ensure_session!
193
201
 
194
202
  params, types = Convert.to_input_params_and_types params, types
@@ -197,17 +205,17 @@ module Google
197
205
  sql, tx_selector, params: params, types: types,
198
206
  partition_size_bytes: partition_size_bytes,
199
207
  max_partitions: max_partitions
200
-
201
208
  results.partitions.map do |grpc|
202
209
  # Convert partition protos to execute sql request protos
203
- execute_sql_grpc = Google::Spanner::V1::ExecuteSqlRequest.new(
210
+ execute_sql_grpc = V1::ExecuteSqlRequest.new(
204
211
  {
205
212
  session: session.path,
206
213
  sql: sql,
207
214
  params: params,
208
215
  param_types: types,
209
216
  transaction: tx_selector,
210
- partition_token: grpc.partition_token
217
+ partition_token: grpc.partition_token,
218
+ query_options: query_options
211
219
  }.delete_if { |_, v| v.nil? }
212
220
  )
213
221
  Partition.from_execute_sql_grpc execute_sql_grpc
@@ -274,7 +282,7 @@ module Google
274
282
 
275
283
  results.partitions.map do |grpc|
276
284
  # Convert partition protos to read request protos
277
- read_grpc = Google::Spanner::V1::ReadRequest.new(
285
+ read_grpc = V1::ReadRequest.new(
278
286
  {
279
287
  session: session.path,
280
288
  table: table,
@@ -415,6 +423,14 @@ module Google
415
423
  # specified using a {Fields} object.
416
424
  #
417
425
  # Types are optional.
426
+ # @param [Hash] query_options A hash of values to specify the custom
427
+ # query options for executing SQL query. Query options are optional.
428
+ # The following settings can be provided:
429
+ #
430
+ # * `:optimizer_version` (String) The version of optimizer to use.
431
+ # Empty to use database default. "latest" to use the latest
432
+ # available optimizer version.
433
+ #
418
434
  # @return [Google::Cloud::Spanner::Results] The results of the query
419
435
  # execution.
420
436
  #
@@ -518,13 +534,29 @@ module Google
518
534
  # puts "User #{row[:id]} is #{row[:name]}"
519
535
  # end
520
536
  #
521
- def execute_query sql, params: nil, types: nil
537
+ # @example Query using query options:
538
+ # require "google/cloud/spanner"
539
+ #
540
+ # spanner = Google::Cloud::Spanner.new
541
+ # batch_client = spanner.batch_client "my-instance", "my-database"
542
+ # batch_snapshot = batch_client.batch_snapshot
543
+ #
544
+ # results = batch_snapshot.execute_query \
545
+ # "SELECT * FROM users",
546
+ # query_options: { optimizer_version: "1" }
547
+ #
548
+ # results.rows.each do |row|
549
+ # puts "User #{row[:id]} is #{row[:name]}"
550
+ # end
551
+ #
552
+ def execute_query sql, params: nil, types: nil, query_options: nil
522
553
  ensure_session!
523
554
 
524
555
  params, types = Convert.to_input_params_and_types params, types
525
556
 
526
557
  session.execute_query sql, params: params, types: types,
527
- transaction: tx_selector
558
+ transaction: tx_selector,
559
+ query_options: query_options
528
560
  end
529
561
  alias execute execute_query
530
562
  alias query execute_query
@@ -628,20 +660,18 @@ module Google
628
660
  ##
629
661
  # @private Loads the serialized batch snapshot. See
630
662
  # {BatchClient#load_batch_snapshot}.
631
- def self.load data, service: nil
663
+ def self.load data, service: nil, query_options: nil
632
664
  data = JSON.parse data, symbolize_names: true unless data.is_a? Hash
633
665
 
634
- session_grpc = Google::Spanner::V1::Session.decode \
635
- Base64.decode64(data[:session])
636
- transaction_grpc = Google::Spanner::V1::Transaction.decode \
637
- Base64.decode64(data[:transaction])
666
+ session_grpc = V1::Session.decode Base64.decode64(data[:session])
667
+ transaction_grpc = V1::Transaction.decode Base64.decode64(data[:transaction])
638
668
 
639
- from_grpc transaction_grpc, Session.from_grpc(session_grpc, service)
669
+ from_grpc transaction_grpc, Session.from_grpc(session_grpc, service, query_options: query_options)
640
670
  end
641
671
 
642
672
  ##
643
673
  # @private Creates a new BatchSnapshot instance from a
644
- # Google::Spanner::V1::Transaction.
674
+ # `Google::Cloud::Spanner::V1::Transaction`.
645
675
  def self.from_grpc grpc, session
646
676
  new grpc, session
647
677
  end
@@ -650,7 +680,7 @@ module Google
650
680
 
651
681
  # The TransactionSelector to be used for queries
652
682
  def tx_selector
653
- Google::Spanner::V1::TransactionSelector.new id: transaction_id
683
+ V1::TransactionSelector.new id: transaction_id
654
684
  end
655
685
 
656
686
  ##
@@ -661,12 +691,15 @@ module Google
661
691
  end
662
692
 
663
693
  def execute_partition_query partition
694
+ query_options = partition.execute.query_options
695
+ query_options = query_options.to_h unless query_options.nil?
664
696
  session.execute_query \
665
697
  partition.execute.sql,
666
698
  params: partition.execute.params,
667
699
  types: partition.execute.param_types.to_h,
668
700
  transaction: partition.execute.transaction,
669
- partition_token: partition.execute.partition_token
701
+ partition_token: partition.execute.partition_token,
702
+ query_options: query_options
670
703
  end
671
704
 
672
705
  def execute_partition_read partition
@@ -155,7 +155,7 @@ module Google
155
155
  Convert.to_input_params_and_types params, types
156
156
  # param_types is a grpc map field, can't be nil
157
157
  converted_types ||= {}
158
- Google::Spanner::V1::ExecuteBatchDmlRequest::Statement.new(
158
+ V1::ExecuteBatchDmlRequest::Statement.new(
159
159
  sql: sql,
160
160
  params: converted_params,
161
161
  param_types: converted_types
@@ -53,12 +53,13 @@ module Google
53
53
  ##
54
54
  # @private Creates a new Spanner Client instance.
55
55
  def initialize project, instance_id, database_id, session_labels: nil,
56
- pool_opts: {}
56
+ pool_opts: {}, query_options: nil
57
57
  @project = project
58
58
  @instance_id = instance_id
59
59
  @database_id = database_id
60
60
  @session_labels = session_labels
61
61
  @pool = Pool.new self, pool_opts
62
+ @query_options = query_options
62
63
  end
63
64
 
64
65
  # The unique identifier for the project.
@@ -97,6 +98,13 @@ module Google
97
98
  @project.database instance_id, database_id
98
99
  end
99
100
 
101
+ # A hash of values to specify the custom query options for executing
102
+ # SQL query.
103
+ # @return [Hash]
104
+ def query_options
105
+ @query_options
106
+ end
107
+
100
108
  ##
101
109
  # Executes a SQL query.
102
110
  #
@@ -207,6 +215,13 @@ module Google
207
215
  # Useful for reading the freshest data available at a nearby
208
216
  # replica, while bounding the possible staleness if the local
209
217
  # replica has fallen behind.
218
+ # @param [Hash] query_options A hash of values to specify the custom
219
+ # query options for executing SQL query. Query options are optional.
220
+ # The following settings can be provided:
221
+ #
222
+ # * `:optimizer_version` (String) The version of optimizer to use.
223
+ # Empty to use database default. "latest" to use the latest
224
+ # available optimizer version.
210
225
  #
211
226
  # @return [Google::Cloud::Spanner::Results] The results of the query
212
227
  # execution.
@@ -306,7 +321,22 @@ module Google
306
321
  # puts "User #{row[:id]} is #{row[:name]}"
307
322
  # end
308
323
  #
309
- def execute_query sql, params: nil, types: nil, single_use: nil
324
+ # @example Query using query options:
325
+ # require "google/cloud/spanner"
326
+ #
327
+ # spanner = Google::Cloud::Spanner.new
328
+ #
329
+ # db = spanner.client "my-instance", "my-database"
330
+ #
331
+ # results = db.execute_query \
332
+ # "SELECT * FROM users", query_options: { optimizer_version: "1" }
333
+ #
334
+ # results.rows.each do |row|
335
+ # puts "User #{row[:id]} is #{row[:name]}"
336
+ # end
337
+ #
338
+ def execute_query sql, params: nil, types: nil, single_use: nil,
339
+ query_options: nil
310
340
  validate_single_use_args! single_use
311
341
  ensure_service!
312
342
 
@@ -316,7 +346,8 @@ module Google
316
346
  results = nil
317
347
  @pool.with_session do |session|
318
348
  results = session.execute_query \
319
- sql, params: params, types: types, transaction: single_use_tx
349
+ sql, params: params, types: types, transaction: single_use_tx,
350
+ query_options: query_options
320
351
  end
321
352
  results
322
353
  end
@@ -443,6 +474,14 @@ module Google
443
474
  # value in `params`. In these cases, the `types` hash can be used to
444
475
  # specify the exact SQL type for some or all of the SQL query
445
476
  # parameters.
477
+ # @param [Hash] query_options A hash of values to specify the custom
478
+ # query options for executing SQL query. Query options are optional.
479
+ # The following settings can be provided:
480
+ #
481
+ # * `:optimizer_version` (String) The version of optimizer to use.
482
+ # Empty to use database default. "latest" to use the latest
483
+ # available optimizer version.
484
+ #
446
485
  #
447
486
  # The keys of the hash should be query string parameter placeholders,
448
487
  # minus the "@". The values of the hash should be Cloud Spanner type
@@ -481,16 +520,26 @@ module Google
481
520
  # "UPDATE users SET friends = NULL WHERE active = @active",
482
521
  # params: { active: false }
483
522
  #
484
- def execute_partition_update sql, params: nil, types: nil
523
+ # @example Query using query options:
524
+ # require "google/cloud/spanner"
525
+ #
526
+ # spanner = Google::Cloud::Spanner.new
527
+ # db = spanner.client "my-instance", "my-database"
528
+ #
529
+ # row_count = db.execute_partition_update \
530
+ # "UPDATE users SET friends = NULL WHERE active = false",
531
+ # query_options: { optimizer_version: "1" }
532
+ def execute_partition_update sql, params: nil, types: nil,
533
+ query_options: nil
485
534
  ensure_service!
486
535
 
487
536
  params, types = Convert.to_input_params_and_types params, types
488
-
489
537
  results = nil
490
538
  @pool.with_session do |session|
491
539
  results = session.execute_query \
492
540
  sql, params: params, types: types,
493
- transaction: pdml_transaction(session)
541
+ transaction: pdml_transaction(session),
542
+ query_options: query_options
494
543
  end
495
544
  # Stream all PartialResultSet to get ResultSetStats
496
545
  results.rows.to_a
@@ -1287,11 +1336,11 @@ module Google
1287
1336
  def create_new_session
1288
1337
  ensure_service!
1289
1338
  grpc = @project.service.create_session \
1290
- Admin::Database::V1::DatabaseAdminClient.database_path(
1291
- project_id, instance_id, database_id
1339
+ Admin::Database::V1::DatabaseAdmin::Paths.database_path(
1340
+ project: project_id, instance: instance_id, database: database_id
1292
1341
  ),
1293
1342
  labels: @session_labels
1294
- Session.from_grpc grpc, @project.service
1343
+ Session.from_grpc grpc, @project.service, query_options: @query_options
1295
1344
  end
1296
1345
 
1297
1346
  ##
@@ -1315,12 +1364,12 @@ module Google
1315
1364
  def batch_create_sessions session_count
1316
1365
  ensure_service!
1317
1366
  resp = @project.service.batch_create_sessions \
1318
- Admin::Database::V1::DatabaseAdminClient.database_path(
1319
- project_id, instance_id, database_id
1367
+ Admin::Database::V1::DatabaseAdmin::Paths.database_path(
1368
+ project: project_id, instance: instance_id, database: database_id
1320
1369
  ),
1321
1370
  session_count,
1322
1371
  labels: @session_labels
1323
- resp.session.map { |grpc| Session.from_grpc grpc, @project.service }
1372
+ resp.session.map { |grpc| Session.from_grpc grpc, @project.service, query_options: @query_options }
1324
1373
  end
1325
1374
 
1326
1375
  # @private
@@ -1372,9 +1421,9 @@ module Google
1372
1421
  bounded_staleness = Convert.number_to_duration \
1373
1422
  opts[:bounded_staleness] || opts[:max_staleness]
1374
1423
 
1375
- Google::Spanner::V1::TransactionSelector.new(single_use:
1376
- Google::Spanner::V1::TransactionOptions.new(read_only:
1377
- Google::Spanner::V1::TransactionOptions::ReadOnly.new({
1424
+ V1::TransactionSelector.new(single_use:
1425
+ V1::TransactionOptions.new(read_only:
1426
+ V1::TransactionOptions::ReadOnly.new({
1378
1427
  strong: opts[:strong],
1379
1428
  read_timestamp: exact_timestamp,
1380
1429
  exact_staleness: exact_staleness,
@@ -1386,7 +1435,7 @@ module Google
1386
1435
 
1387
1436
  def pdml_transaction session
1388
1437
  pdml_tx_grpc = @project.service.create_pdml session.path
1389
- Google::Spanner::V1::TransactionSelector.new id: pdml_tx_grpc.id
1438
+ V1::TransactionSelector.new id: pdml_tx_grpc.id
1390
1439
  end
1391
1440
 
1392
1441
  ##
@@ -96,8 +96,8 @@ module Google
96
96
  rows.delete_if(&:nil?)
97
97
  rows.delete_if(&:empty?)
98
98
  @mutations += rows.map do |row|
99
- Google::Spanner::V1::Mutation.new(
100
- insert_or_update: Google::Spanner::V1::Mutation::Write.new(
99
+ V1::Mutation.new(
100
+ insert_or_update: V1::Mutation::Write.new(
101
101
  table: table, columns: row.keys.map(&:to_s),
102
102
  values: [Convert.object_to_grpc_value(row.values).list_value]
103
103
  )
@@ -154,8 +154,8 @@ module Google
154
154
  rows.delete_if(&:nil?)
155
155
  rows.delete_if(&:empty?)
156
156
  @mutations += rows.map do |row|
157
- Google::Spanner::V1::Mutation.new(
158
- insert: Google::Spanner::V1::Mutation::Write.new(
157
+ V1::Mutation.new(
158
+ insert: V1::Mutation::Write.new(
159
159
  table: table, columns: row.keys.map(&:to_s),
160
160
  values: [Convert.object_to_grpc_value(row.values).list_value]
161
161
  )
@@ -211,8 +211,8 @@ module Google
211
211
  rows.delete_if(&:nil?)
212
212
  rows.delete_if(&:empty?)
213
213
  @mutations += rows.map do |row|
214
- Google::Spanner::V1::Mutation.new(
215
- update: Google::Spanner::V1::Mutation::Write.new(
214
+ V1::Mutation.new(
215
+ update: V1::Mutation::Write.new(
216
216
  table: table, columns: row.keys.map(&:to_s),
217
217
  values: [Convert.object_to_grpc_value(row.values).list_value]
218
218
  )
@@ -270,8 +270,8 @@ module Google
270
270
  rows.delete_if(&:nil?)
271
271
  rows.delete_if(&:empty?)
272
272
  @mutations += rows.map do |row|
273
- Google::Spanner::V1::Mutation.new(
274
- replace: Google::Spanner::V1::Mutation::Write.new(
273
+ V1::Mutation.new(
274
+ replace: V1::Mutation::Write.new(
275
275
  table: table, columns: row.keys.map(&:to_s),
276
276
  values: [Convert.object_to_grpc_value(row.values).list_value]
277
277
  )
@@ -306,8 +306,8 @@ module Google
306
306
  #
307
307
  def delete table, keys = []
308
308
  @mutations += [
309
- Google::Spanner::V1::Mutation.new(
310
- delete: Google::Spanner::V1::Mutation::Delete.new(
309
+ V1::Mutation.new(
310
+ delete: V1::Mutation::Delete.new(
311
311
  table: table, key_set: key_set(keys)
312
312
  )
313
313
  )
@@ -323,20 +323,20 @@ module Google
323
323
  protected
324
324
 
325
325
  def key_set keys
326
- return Google::Spanner::V1::KeySet.new all: true if keys.nil?
326
+ return V1::KeySet.new all: true if keys.nil?
327
327
  keys = [keys] unless keys.is_a? Array
328
- return Google::Spanner::V1::KeySet.new all: true if keys.empty?
328
+ return V1::KeySet.new all: true if keys.empty?
329
329
  if keys_are_ranges? keys
330
330
  key_ranges = keys.map do |r|
331
331
  Convert.to_key_range r
332
332
  end
333
- return Google::Spanner::V1::KeySet.new ranges: key_ranges
333
+ return V1::KeySet.new ranges: key_ranges
334
334
  end
335
335
  key_list = keys.map do |key|
336
336
  key = [key] unless key.is_a? Array
337
337
  Convert.object_to_grpc_value(key).list_value
338
338
  end
339
- Google::Spanner::V1::KeySet.new keys: key_list
339
+ V1::KeySet.new keys: key_list
340
340
  end
341
341
 
342
342
  def keys_are_ranges? keys
@@ -169,12 +169,12 @@ module Google
169
169
  return field.to_grpc_type if field.respond_to? :to_grpc_type
170
170
 
171
171
  if Array === field
172
- Google::Spanner::V1::Type.new(
172
+ V1::Type.new(
173
173
  code: :ARRAY,
174
174
  array_element_type: grpc_type_for_field(field.first)
175
175
  )
176
176
  else
177
- Google::Spanner::V1::Type.new(code: field)
177
+ V1::Type.new(code: field)
178
178
  end
179
179
  end
180
180
 
@@ -274,24 +274,24 @@ module Google
274
274
  range_opts.delete :end_closed
275
275
  end
276
276
 
277
- Google::Spanner::V1::KeyRange.new range_opts
277
+ V1::KeyRange.new range_opts
278
278
  end
279
279
 
280
280
  def to_key_set keys
281
- return Google::Spanner::V1::KeySet.new(all: true) if keys.nil?
281
+ return V1::KeySet.new(all: true) if keys.nil?
282
282
  keys = [keys] unless keys.is_a? Array
283
- return Google::Spanner::V1::KeySet.new(all: true) if keys.empty?
283
+ return V1::KeySet.new(all: true) if keys.empty?
284
284
 
285
285
  if keys_are_ranges? keys
286
286
  key_ranges = keys.map { |r| to_key_range(r) }
287
- return Google::Spanner::V1::KeySet.new(ranges: key_ranges)
287
+ return V1::KeySet.new(ranges: key_ranges)
288
288
  end
289
289
 
290
290
  key_list = keys.map do |key|
291
291
  key = [key] unless key.is_a? Array
292
292
  object_to_grpc_value(key).list_value
293
293
  end
294
- Google::Spanner::V1::KeySet.new keys: key_list
294
+ V1::KeySet.new keys: key_list
295
295
  end
296
296
 
297
297
  def keys_are_ranges? keys