google-cloud-bigquery 1.31.0 → 1.34.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -416,6 +416,49 @@ module Google
416
416
  @gapi.configuration.load.hive_partitioning_options.source_uri_prefix if hive_partitioning?
417
417
  end
418
418
 
419
+ ###
420
+ # Checks if Parquet options are set.
421
+ #
422
+ # @see https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-parquet Loading Parquet data from Cloud
423
+ # Storage
424
+ #
425
+ # @return [Boolean] `true` when Parquet options are set, or `false` otherwise.
426
+ #
427
+ # @!group Attributes
428
+ #
429
+ def parquet_options?
430
+ !@gapi.configuration.load.parquet_options.nil?
431
+ end
432
+
433
+ ###
434
+ # Indicates whether to use schema inference specifically for Parquet `LIST` logical type.
435
+ #
436
+ # @see https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-parquet Loading Parquet data from Cloud
437
+ # Storage
438
+ #
439
+ # @return [Boolean, nil] The `enable_list_inference` value in Parquet options, or `nil` if Parquet options are
440
+ # not set.
441
+ #
442
+ # @!group Attributes
443
+ #
444
+ def parquet_enable_list_inference?
445
+ @gapi.configuration.load.parquet_options.enable_list_inference if parquet_options?
446
+ end
447
+
448
+ ###
449
+ # Indicates whether to infer Parquet `ENUM` logical type as `STRING` instead of `BYTES` by default.
450
+ #
451
+ # @see https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-parquet Loading Parquet data from Cloud
452
+ # Storage
453
+ #
454
+ # @return [Boolean, nil] The `enum_as_string` value in Parquet options, or `nil` if Parquet options are not set.
455
+ #
456
+ # @!group Attributes
457
+ #
458
+ def parquet_enum_as_string?
459
+ @gapi.configuration.load.parquet_options.enum_as_string if parquet_options?
460
+ end
461
+
419
462
  ###
420
463
  # Checks if the destination table will be range partitioned. See [Creating and using integer range partitioned
421
464
  # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
@@ -708,6 +751,12 @@ module Google
708
751
  # @param [Symbol] mode The field's mode. The possible values are
709
752
  # `:nullable`, `:required`, and `:repeated`. The default value is
710
753
  # `:nullable`.
754
+ # @param [Array<String>, String] policy_tags The policy tag list or
755
+ # single policy tag for the field. Policy tag identifiers are of
756
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
757
+ # At most 1 policy tag is currently allowed.
758
+ # @param [Integer] max_length The maximum UTF-8 length of strings
759
+ # allowed in the field.
711
760
  #
712
761
  # @example
713
762
  # require "google/cloud/bigquery"
@@ -719,8 +768,8 @@ module Google
719
768
  # end
720
769
  #
721
770
  # @!group Schema
722
- def string name, description: nil, mode: :nullable
723
- schema.string name, description: description, mode: mode
771
+ def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
772
+ schema.string name, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length
724
773
  end
725
774
 
726
775
  ##
@@ -736,6 +785,10 @@ module Google
736
785
  # @param [Symbol] mode The field's mode. The possible values are
737
786
  # `:nullable`, `:required`, and `:repeated`. The default value is
738
787
  # `:nullable`.
788
+ # @param [Array<String>, String] policy_tags The policy tag list or
789
+ # single policy tag for the field. Policy tag identifiers are of
790
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
791
+ # At most 1 policy tag is currently allowed.
739
792
  #
740
793
  # @example
741
794
  # require "google/cloud/bigquery"
@@ -747,8 +800,8 @@ module Google
747
800
  # end
748
801
  #
749
802
  # @!group Schema
750
- def integer name, description: nil, mode: :nullable
751
- schema.integer name, description: description, mode: mode
803
+ def integer name, description: nil, mode: :nullable, policy_tags: nil
804
+ schema.integer name, description: description, mode: mode, policy_tags: policy_tags
752
805
  end
753
806
 
754
807
  ##
@@ -764,6 +817,10 @@ module Google
764
817
  # @param [Symbol] mode The field's mode. The possible values are
765
818
  # `:nullable`, `:required`, and `:repeated`. The default value is
766
819
  # `:nullable`.
820
+ # @param [Array<String>, String] policy_tags The policy tag list or
821
+ # single policy tag for the field. Policy tag identifiers are of
822
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
823
+ # At most 1 policy tag is currently allowed.
767
824
  #
768
825
  # @example
769
826
  # require "google/cloud/bigquery"
@@ -775,8 +832,8 @@ module Google
775
832
  # end
776
833
  #
777
834
  # @!group Schema
778
- def float name, description: nil, mode: :nullable
779
- schema.float name, description: description, mode: mode
835
+ def float name, description: nil, mode: :nullable, policy_tags: nil
836
+ schema.float name, description: description, mode: mode, policy_tags: policy_tags
780
837
  end
781
838
 
782
839
  ##
@@ -803,6 +860,20 @@ module Google
803
860
  # @param [Symbol] mode The field's mode. The possible values are
804
861
  # `:nullable`, `:required`, and `:repeated`. The default value is
805
862
  # `:nullable`.
863
+ # @param [Array<String>, String] policy_tags The policy tag list or
864
+ # single policy tag for the field. Policy tag identifiers are of
865
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
866
+ # At most 1 policy tag is currently allowed.
867
+ # @param [Integer] precision The precision (maximum number of total
868
+ # digits) for the field. Acceptable values for precision must be:
869
+ # `1 ≤ (precision - scale) ≤ 29`. Values for scale must be:
870
+ # `0 ≤ scale ≤ 9`. If the scale value is set, the precision value
871
+ # must be set as well.
872
+ # @param [Integer] scale The scale (maximum number of digits in the
873
+ # fractional part) for the field. Acceptable values for precision
874
+ # must be: `1 ≤ (precision - scale) ≤ 29`. Values for scale must
875
+ # be: `0 ≤ scale ≤ 9`. If the scale value is set, the precision
876
+ # value must be set as well.
806
877
  #
807
878
  # @example
808
879
  # require "google/cloud/bigquery"
@@ -814,8 +885,13 @@ module Google
814
885
  # end
815
886
  #
816
887
  # @!group Schema
817
- def numeric name, description: nil, mode: :nullable
818
- schema.numeric name, description: description, mode: mode
888
+ def numeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
889
+ schema.numeric name,
890
+ description: description,
891
+ mode: mode,
892
+ policy_tags: policy_tags,
893
+ precision: precision,
894
+ scale: scale
819
895
  end
820
896
 
821
897
  ##
@@ -842,6 +918,20 @@ module Google
842
918
  # @param [Symbol] mode The field's mode. The possible values are
843
919
  # `:nullable`, `:required`, and `:repeated`. The default value is
844
920
  # `:nullable`.
921
+ # @param [Array<String>, String] policy_tags The policy tag list or
922
+ # single policy tag for the field. Policy tag identifiers are of
923
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
924
+ # At most 1 policy tag is currently allowed.
925
+ # @param [Integer] precision The precision (maximum number of total
926
+ # digits) for the field. Acceptable values for precision must be:
927
+ # `1 ≤ (precision - scale) ≤ 38`. Values for scale must be:
928
+ # `0 ≤ scale ≤ 38`. If the scale value is set, the precision value
929
+ # must be set as well.
930
+ # @param [Integer] scale The scale (maximum number of digits in the
931
+ # fractional part) for the field. Acceptable values for precision
932
+ # must be: `1 ≤ (precision - scale) ≤ 38`. Values for scale must
933
+ # be: `0 ≤ scale ≤ 38`. If the scale value is set, the precision
934
+ # value must be set as well.
845
935
  #
846
936
  # @example
847
937
  # require "google/cloud/bigquery"
@@ -853,8 +943,13 @@ module Google
853
943
  # end
854
944
  #
855
945
  # @!group Schema
856
- def bignumeric name, description: nil, mode: :nullable
857
- schema.bignumeric name, description: description, mode: mode
946
+ def bignumeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
947
+ schema.bignumeric name,
948
+ description: description,
949
+ mode: mode,
950
+ policy_tags: policy_tags,
951
+ precision: precision,
952
+ scale: scale
858
953
  end
859
954
 
860
955
  ##
@@ -870,6 +965,10 @@ module Google
870
965
  # @param [Symbol] mode The field's mode. The possible values are
871
966
  # `:nullable`, `:required`, and `:repeated`. The default value is
872
967
  # `:nullable`.
968
+ # @param [Array<String>, String] policy_tags The policy tag list or
969
+ # single policy tag for the field. Policy tag identifiers are of
970
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
971
+ # At most 1 policy tag is currently allowed.
873
972
  #
874
973
  # @example
875
974
  # require "google/cloud/bigquery"
@@ -881,8 +980,8 @@ module Google
881
980
  # end
882
981
  #
883
982
  # @!group Schema
884
- def boolean name, description: nil, mode: :nullable
885
- schema.boolean name, description: description, mode: mode
983
+ def boolean name, description: nil, mode: :nullable, policy_tags: nil
984
+ schema.boolean name, description: description, mode: mode, policy_tags: policy_tags
886
985
  end
887
986
 
888
987
  ##
@@ -898,6 +997,12 @@ module Google
898
997
  # @param [Symbol] mode The field's mode. The possible values are
899
998
  # `:nullable`, `:required`, and `:repeated`. The default value is
900
999
  # `:nullable`.
1000
+ # @param [Array<String>, String] policy_tags The policy tag list or
1001
+ # single policy tag for the field. Policy tag identifiers are of
1002
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
1003
+ # At most 1 policy tag is currently allowed.
1004
+ # @param [Integer] max_length The maximum the maximum number of
1005
+ # bytes in the field.
901
1006
  #
902
1007
  # @example
903
1008
  # require "google/cloud/bigquery"
@@ -909,8 +1014,8 @@ module Google
909
1014
  # end
910
1015
  #
911
1016
  # @!group Schema
912
- def bytes name, description: nil, mode: :nullable
913
- schema.bytes name, description: description, mode: mode
1017
+ def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
1018
+ schema.bytes name, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length
914
1019
  end
915
1020
 
916
1021
  ##
@@ -926,6 +1031,10 @@ module Google
926
1031
  # @param [Symbol] mode The field's mode. The possible values are
927
1032
  # `:nullable`, `:required`, and `:repeated`. The default value is
928
1033
  # `:nullable`.
1034
+ # @param [Array<String>, String] policy_tags The policy tag list or
1035
+ # single policy tag for the field. Policy tag identifiers are of
1036
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
1037
+ # At most 1 policy tag is currently allowed.
929
1038
  #
930
1039
  # @example
931
1040
  # require "google/cloud/bigquery"
@@ -937,8 +1046,8 @@ module Google
937
1046
  # end
938
1047
  #
939
1048
  # @!group Schema
940
- def timestamp name, description: nil, mode: :nullable
941
- schema.timestamp name, description: description, mode: mode
1049
+ def timestamp name, description: nil, mode: :nullable, policy_tags: nil
1050
+ schema.timestamp name, description: description, mode: mode, policy_tags: policy_tags
942
1051
  end
943
1052
 
944
1053
  ##
@@ -954,6 +1063,10 @@ module Google
954
1063
  # @param [Symbol] mode The field's mode. The possible values are
955
1064
  # `:nullable`, `:required`, and `:repeated`. The default value is
956
1065
  # `:nullable`.
1066
+ # @param [Array<String>, String] policy_tags The policy tag list or
1067
+ # single policy tag for the field. Policy tag identifiers are of
1068
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
1069
+ # At most 1 policy tag is currently allowed.
957
1070
  #
958
1071
  # @example
959
1072
  # require "google/cloud/bigquery"
@@ -965,8 +1078,8 @@ module Google
965
1078
  # end
966
1079
  #
967
1080
  # @!group Schema
968
- def time name, description: nil, mode: :nullable
969
- schema.time name, description: description, mode: mode
1081
+ def time name, description: nil, mode: :nullable, policy_tags: nil
1082
+ schema.time name, description: description, mode: mode, policy_tags: policy_tags
970
1083
  end
971
1084
 
972
1085
  ##
@@ -982,6 +1095,10 @@ module Google
982
1095
  # @param [Symbol] mode The field's mode. The possible values are
983
1096
  # `:nullable`, `:required`, and `:repeated`. The default value is
984
1097
  # `:nullable`.
1098
+ # @param [Array<String>, String] policy_tags The policy tag list or
1099
+ # single policy tag for the field. Policy tag identifiers are of
1100
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
1101
+ # At most 1 policy tag is currently allowed.
985
1102
  #
986
1103
  # @example
987
1104
  # require "google/cloud/bigquery"
@@ -993,8 +1110,8 @@ module Google
993
1110
  # end
994
1111
  #
995
1112
  # @!group Schema
996
- def datetime name, description: nil, mode: :nullable
997
- schema.datetime name, description: description, mode: mode
1113
+ def datetime name, description: nil, mode: :nullable, policy_tags: nil
1114
+ schema.datetime name, description: description, mode: mode, policy_tags: policy_tags
998
1115
  end
999
1116
 
1000
1117
  ##
@@ -1010,6 +1127,10 @@ module Google
1010
1127
  # @param [Symbol] mode The field's mode. The possible values are
1011
1128
  # `:nullable`, `:required`, and `:repeated`. The default value is
1012
1129
  # `:nullable`.
1130
+ # @param [Array<String>, String] policy_tags The policy tag list or
1131
+ # single policy tag for the field. Policy tag identifiers are of
1132
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
1133
+ # At most 1 policy tag is currently allowed.
1013
1134
  #
1014
1135
  # @example
1015
1136
  # require "google/cloud/bigquery"
@@ -1021,8 +1142,8 @@ module Google
1021
1142
  # end
1022
1143
  #
1023
1144
  # @!group Schema
1024
- def date name, description: nil, mode: :nullable
1025
- schema.date name, description: description, mode: mode
1145
+ def date name, description: nil, mode: :nullable, policy_tags: nil
1146
+ schema.date name, description: description, mode: mode, policy_tags: policy_tags
1026
1147
  end
1027
1148
 
1028
1149
  ##
@@ -1534,6 +1655,66 @@ module Google
1534
1655
  @gapi.configuration.load.hive_partitioning_options.source_uri_prefix = source_uri_prefix
1535
1656
  end
1536
1657
 
1658
+ ##
1659
+ # Sets whether to use schema inference specifically for Parquet `LIST` logical type.
1660
+ #
1661
+ # @see https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-parquet Loading Parquet data from
1662
+ # Cloud Storage
1663
+ #
1664
+ # @param [Boolean] enable_list_inference The `enable_list_inference` value to use in Parquet options.
1665
+ #
1666
+ # @example
1667
+ # require "google/cloud/bigquery"
1668
+ #
1669
+ # bigquery = Google::Cloud::Bigquery.new
1670
+ # dataset = bigquery.dataset "my_dataset"
1671
+ #
1672
+ # gcs_uris = ["gs://mybucket/00/*.parquet", "gs://mybucket/01/*.parquet"]
1673
+ # load_job = dataset.load_job "my_new_table", gcs_uris do |job|
1674
+ # job.format = :parquet
1675
+ # job.parquet_enable_list_inference = true
1676
+ # end
1677
+ #
1678
+ # load_job.wait_until_done!
1679
+ # load_job.done? #=> true
1680
+ #
1681
+ # @!group Attributes
1682
+ #
1683
+ def parquet_enable_list_inference= enable_list_inference
1684
+ @gapi.configuration.load.parquet_options ||= Google::Apis::BigqueryV2::ParquetOptions.new
1685
+ @gapi.configuration.load.parquet_options.enable_list_inference = enable_list_inference
1686
+ end
1687
+
1688
+ ##
1689
+ # Sets whether to infer Parquet `ENUM` logical type as `STRING` instead of `BYTES` by default.
1690
+ #
1691
+ # @see https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-parquet Loading Parquet data from
1692
+ # Cloud Storage
1693
+ #
1694
+ # @param [Boolean] enum_as_string The `enum_as_string` value to use in Parquet options.
1695
+ #
1696
+ # @example
1697
+ # require "google/cloud/bigquery"
1698
+ #
1699
+ # bigquery = Google::Cloud::Bigquery.new
1700
+ # dataset = bigquery.dataset "my_dataset"
1701
+ #
1702
+ # gcs_uris = ["gs://mybucket/00/*.parquet", "gs://mybucket/01/*.parquet"]
1703
+ # load_job = dataset.load_job "my_new_table", gcs_uris do |job|
1704
+ # job.format = :parquet
1705
+ # job.parquet_enum_as_string = true
1706
+ # end
1707
+ #
1708
+ # load_job.wait_until_done!
1709
+ # load_job.done? #=> true
1710
+ #
1711
+ # @!group Attributes
1712
+ #
1713
+ def parquet_enum_as_string= enum_as_string
1714
+ @gapi.configuration.load.parquet_options ||= Google::Apis::BigqueryV2::ParquetOptions.new
1715
+ @gapi.configuration.load.parquet_options.enum_as_string = enum_as_string
1716
+ end
1717
+
1537
1718
  ##
1538
1719
  # Sets the field on which to range partition the table. See [Creating and using integer range partitioned
1539
1720
  # tables](https://cloud.google.com/bigquery/docs/creating-integer-range-partitions).
@@ -386,6 +386,39 @@ module Google
386
386
  @gapi.statistics.query.num_dml_affected_rows
387
387
  end
388
388
 
389
+ ##
390
+ # The number of deleted rows. Present only for DML statements `DELETE`,
391
+ # `MERGE` and `TRUNCATE`. (See {#statement_type}.)
392
+ #
393
+ # @return [Integer, nil] The number of deleted rows, or `nil` if not
394
+ # applicable.
395
+ #
396
+ def deleted_row_count
397
+ @gapi.statistics.query&.dml_stats&.deleted_row_count
398
+ end
399
+
400
+ ##
401
+ # The number of inserted rows. Present only for DML statements `INSERT`
402
+ # and `MERGE`. (See {#statement_type}.)
403
+ #
404
+ # @return [Integer, nil] The number of inserted rows, or `nil` if not
405
+ # applicable.
406
+ #
407
+ def inserted_row_count
408
+ @gapi.statistics.query&.dml_stats&.inserted_row_count
409
+ end
410
+
411
+ ##
412
+ # The number of updated rows. Present only for DML statements `UPDATE`
413
+ # and `MERGE`. (See {#statement_type}.)
414
+ #
415
+ # @return [Integer, nil] The number of updated rows, or `nil` if not
416
+ # applicable.
417
+ #
418
+ def updated_row_count
419
+ @gapi.statistics.query&.dml_stats&.updated_row_count
420
+ end
421
+
389
422
  ##
390
423
  # The table in which the query results are stored.
391
424
  #
@@ -294,9 +294,20 @@ module Google
294
294
  # @param [Symbol] mode The field's mode. The possible values are
295
295
  # `:nullable`, `:required`, and `:repeated`. The default value is
296
296
  # `:nullable`.
297
- #
298
- def string name, description: nil, mode: :nullable
299
- add_field name, :string, description: description, mode: mode
297
+ # @param [Array<String>, String] policy_tags The policy tag list or
298
+ # single policy tag for the field. Policy tag identifiers are of
299
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
300
+ # At most 1 policy tag is currently allowed.
301
+ # @param [Integer] max_length The maximum UTF-8 length of strings
302
+ # allowed in the field.
303
+ #
304
+ def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
305
+ add_field name,
306
+ :string,
307
+ description: description,
308
+ mode: mode,
309
+ policy_tags: policy_tags,
310
+ max_length: max_length
300
311
  end
301
312
 
302
313
  ##
@@ -310,9 +321,13 @@ module Google
310
321
  # @param [Symbol] mode The field's mode. The possible values are
311
322
  # `:nullable`, `:required`, and `:repeated`. The default value is
312
323
  # `:nullable`.
324
+ # @param [Array<String>, String] policy_tags The policy tag list or
325
+ # single policy tag for the field. Policy tag identifiers are of
326
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
327
+ # At most 1 policy tag is currently allowed.
313
328
  #
314
- def integer name, description: nil, mode: :nullable
315
- add_field name, :integer, description: description, mode: mode
329
+ def integer name, description: nil, mode: :nullable, policy_tags: nil
330
+ add_field name, :integer, description: description, mode: mode, policy_tags: policy_tags
316
331
  end
317
332
 
318
333
  ##
@@ -326,9 +341,13 @@ module Google
326
341
  # @param [Symbol] mode The field's mode. The possible values are
327
342
  # `:nullable`, `:required`, and `:repeated`. The default value is
328
343
  # `:nullable`.
344
+ # @param [Array<String>, String] policy_tags The policy tag list or
345
+ # single policy tag for the field. Policy tag identifiers are of
346
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
347
+ # At most 1 policy tag is currently allowed.
329
348
  #
330
- def float name, description: nil, mode: :nullable
331
- add_field name, :float, description: description, mode: mode
349
+ def float name, description: nil, mode: :nullable, policy_tags: nil
350
+ add_field name, :float, description: description, mode: mode, policy_tags: policy_tags
332
351
  end
333
352
 
334
353
  ##
@@ -353,9 +372,29 @@ module Google
353
372
  # @param [Symbol] mode The field's mode. The possible values are
354
373
  # `:nullable`, `:required`, and `:repeated`. The default value is
355
374
  # `:nullable`.
356
- #
357
- def numeric name, description: nil, mode: :nullable
358
- add_field name, :numeric, description: description, mode: mode
375
+ # @param [Array<String>, String] policy_tags The policy tag list or
376
+ # single policy tag for the field. Policy tag identifiers are of
377
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
378
+ # At most 1 policy tag is currently allowed.
379
+ # @param [Integer] precision The precision (maximum number of total
380
+ # digits) for the field. Acceptable values for precision must be:
381
+ # `1 ≤ (precision - scale) ≤ 29`. Values for scale must be:
382
+ # `0 ≤ scale ≤ 9`. If the scale value is set, the precision value
383
+ # must be set as well.
384
+ # @param [Integer] scale The scale (maximum number of digits in the
385
+ # fractional part) for the field. Acceptable values for precision
386
+ # must be: `1 ≤ (precision - scale) ≤ 29`. Values for scale must
387
+ # be: `0 ≤ scale ≤ 9`. If the scale value is set, the precision
388
+ # value must be set as well.
389
+ #
390
+ def numeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
391
+ add_field name,
392
+ :numeric,
393
+ description: description,
394
+ mode: mode,
395
+ policy_tags: policy_tags,
396
+ precision: precision,
397
+ scale: scale
359
398
  end
360
399
 
361
400
  ##
@@ -380,9 +419,29 @@ module Google
380
419
  # @param [Symbol] mode The field's mode. The possible values are
381
420
  # `:nullable`, `:required`, and `:repeated`. The default value is
382
421
  # `:nullable`.
383
- #
384
- def bignumeric name, description: nil, mode: :nullable
385
- add_field name, :bignumeric, description: description, mode: mode
422
+ # @param [Array<String>, String] policy_tags The policy tag list or
423
+ # single policy tag for the field. Policy tag identifiers are of
424
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
425
+ # At most 1 policy tag is currently allowed.
426
+ # @param [Integer] precision The precision (maximum number of total
427
+ # digits) for the field. Acceptable values for precision must be:
428
+ # `1 ≤ (precision - scale) ≤ 38`. Values for scale must be:
429
+ # `0 ≤ scale ≤ 38`. If the scale value is set, the precision value
430
+ # must be set as well.
431
+ # @param [Integer] scale The scale (maximum number of digits in the
432
+ # fractional part) for the field. Acceptable values for precision
433
+ # must be: `1 ≤ (precision - scale) ≤ 38`. Values for scale must
434
+ # be: `0 ≤ scale ≤ 38`. If the scale value is set, the precision
435
+ # value must be set as well.
436
+ #
437
+ def bignumeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
438
+ add_field name,
439
+ :bignumeric,
440
+ description: description,
441
+ mode: mode,
442
+ policy_tags: policy_tags,
443
+ precision: precision,
444
+ scale: scale
386
445
  end
387
446
 
388
447
  ##
@@ -396,9 +455,13 @@ module Google
396
455
  # @param [Symbol] mode The field's mode. The possible values are
397
456
  # `:nullable`, `:required`, and `:repeated`. The default value is
398
457
  # `:nullable`.
458
+ # @param [Array<String>, String] policy_tags The policy tag list or
459
+ # single policy tag for the field. Policy tag identifiers are of
460
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
461
+ # At most 1 policy tag is currently allowed.
399
462
  #
400
- def boolean name, description: nil, mode: :nullable
401
- add_field name, :boolean, description: description, mode: mode
463
+ def boolean name, description: nil, mode: :nullable, policy_tags: nil
464
+ add_field name, :boolean, description: description, mode: mode, policy_tags: policy_tags
402
465
  end
403
466
 
404
467
  ##
@@ -412,9 +475,15 @@ module Google
412
475
  # @param [Symbol] mode The field's mode. The possible values are
413
476
  # `:nullable`, `:required`, and `:repeated`. The default value is
414
477
  # `:nullable`.
415
- #
416
- def bytes name, description: nil, mode: :nullable
417
- add_field name, :bytes, description: description, mode: mode
478
+ # @param [Array<String>, String] policy_tags The policy tag list or
479
+ # single policy tag for the field. Policy tag identifiers are of
480
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
481
+ # At most 1 policy tag is currently allowed.
482
+ # @param [Integer] max_length The maximum the maximum number of
483
+ # bytes in the field.
484
+ #
485
+ def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
486
+ add_field name, :bytes, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length
418
487
  end
419
488
 
420
489
  ##
@@ -428,8 +497,13 @@ module Google
428
497
  # @param [Symbol] mode The field's mode. The possible values are
429
498
  # `:nullable`, `:required`, and `:repeated`. The default value is
430
499
  # `:nullable`.
431
- def timestamp name, description: nil, mode: :nullable
432
- add_field name, :timestamp, description: description, mode: mode
500
+ # @param [Array<String>, String] policy_tags The policy tag list or
501
+ # single policy tag for the field. Policy tag identifiers are of
502
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
503
+ # At most 1 policy tag is currently allowed.
504
+ #
505
+ def timestamp name, description: nil, mode: :nullable, policy_tags: nil
506
+ add_field name, :timestamp, description: description, mode: mode, policy_tags: policy_tags
433
507
  end
434
508
 
435
509
  ##
@@ -443,9 +517,13 @@ module Google
443
517
  # @param [Symbol] mode The field's mode. The possible values are
444
518
  # `:nullable`, `:required`, and `:repeated`. The default value is
445
519
  # `:nullable`.
520
+ # @param [Array<String>, String] policy_tags The policy tag list or
521
+ # single policy tag for the field. Policy tag identifiers are of
522
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
523
+ # At most 1 policy tag is currently allowed.
446
524
  #
447
- def time name, description: nil, mode: :nullable
448
- add_field name, :time, description: description, mode: mode
525
+ def time name, description: nil, mode: :nullable, policy_tags: nil
526
+ add_field name, :time, description: description, mode: mode, policy_tags: policy_tags
449
527
  end
450
528
 
451
529
  ##
@@ -459,9 +537,13 @@ module Google
459
537
  # @param [Symbol] mode The field's mode. The possible values are
460
538
  # `:nullable`, `:required`, and `:repeated`. The default value is
461
539
  # `:nullable`.
540
+ # @param [Array<String>, String] policy_tags The policy tag list or
541
+ # single policy tag for the field. Policy tag identifiers are of
542
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
543
+ # At most 1 policy tag is currently allowed.
462
544
  #
463
- def datetime name, description: nil, mode: :nullable
464
- add_field name, :datetime, description: description, mode: mode
545
+ def datetime name, description: nil, mode: :nullable, policy_tags: nil
546
+ add_field name, :datetime, description: description, mode: mode, policy_tags: policy_tags
465
547
  end
466
548
 
467
549
  ##
@@ -475,9 +557,13 @@ module Google
475
557
  # @param [Symbol] mode The field's mode. The possible values are
476
558
  # `:nullable`, `:required`, and `:repeated`. The default value is
477
559
  # `:nullable`.
560
+ # @param [Array<String>, String] policy_tags The policy tag list or
561
+ # single policy tag for the field. Policy tag identifiers are of
562
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
563
+ # At most 1 policy tag is currently allowed.
478
564
  #
479
- def date name, description: nil, mode: :nullable
480
- add_field name, :date, description: description, mode: mode
565
+ def date name, description: nil, mode: :nullable, policy_tags: nil
566
+ add_field name, :date, description: description, mode: mode, policy_tags: policy_tags
481
567
  end
482
568
 
483
569
  ##
@@ -560,7 +646,14 @@ module Google
560
646
  raise ArgumentError, "Cannot modify a frozen schema"
561
647
  end
562
648
 
563
- def add_field name, type, description: nil, mode: :nullable
649
+ def add_field name,
650
+ type,
651
+ description: nil,
652
+ mode: :nullable,
653
+ policy_tags: nil,
654
+ max_length: nil,
655
+ precision: nil,
656
+ scale: nil
564
657
  frozen_check!
565
658
 
566
659
  new_gapi = Google::Apis::BigqueryV2::TableFieldSchema.new(
@@ -570,7 +663,13 @@ module Google
570
663
  mode: verify_mode(mode),
571
664
  fields: []
572
665
  )
573
-
666
+ if policy_tags
667
+ policy_tags = Array(policy_tags)
668
+ new_gapi.policy_tags = Google::Apis::BigqueryV2::TableFieldSchema::PolicyTags.new names: policy_tags
669
+ end
670
+ new_gapi.max_length = max_length if max_length
671
+ new_gapi.precision = precision if precision
672
+ new_gapi.scale = scale if scale
574
673
  # Remove any existing field of this name
575
674
  @gapi.fields ||= []
576
675
  @gapi.fields.reject! { |f| f.name == new_gapi.name }