google-cloud-bigquery 1.32.1 → 1.35.1

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.
@@ -87,8 +87,8 @@ module Google
87
87
  ##
88
88
  # A unique ID for this model.
89
89
  #
90
- # @return [String] The ID must contain only letters (a-z, A-Z), numbers
91
- # (0-9), or underscores (_). The maximum length is 1,024 characters.
90
+ # @return [String] The ID must contain only letters (`[A-Za-z]`), numbers
91
+ # (`[0-9]`), or underscores (`_`). The maximum length is 1,024 characters.
92
92
  #
93
93
  # @!group Attributes
94
94
  #
@@ -100,8 +100,8 @@ module Google
100
100
  ##
101
101
  # The ID of the `Dataset` containing this model.
102
102
  #
103
- # @return [String] The ID must contain only letters (a-z, A-Z), numbers
104
- # (0-9), or underscores (_). The maximum length is 1,024 characters.
103
+ # @return [String] The ID must contain only letters (`[A-Za-z]`), numbers
104
+ # (`[0-9]`), or underscores (`_`). The maximum length is 1,024 characters.
105
105
  #
106
106
  # @!group Attributes
107
107
  #
@@ -515,8 +515,8 @@ module Google
515
515
  # * `ml_tf_saved_model` - TensorFlow SavedModel
516
516
  # * `ml_xgboost_booster` - XGBoost Booster
517
517
  # @param [String] job_id A user-defined ID for the extract job. The ID
518
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
519
- # (_), or dashes (-). The maximum length is 1,024 characters. If
518
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
519
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
520
520
  # `job_id` is provided, then `prefix` will not be used.
521
521
  #
522
522
  # See [Generating a job
@@ -525,8 +525,8 @@ module Google
525
525
  # prepended to a generated value to produce a unique job ID. For
526
526
  # example, the prefix `daily_import_job_` can be given to generate a
527
527
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
528
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
529
- # underscores (_), or dashes (-). The maximum length of the entire ID
528
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
529
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
530
530
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
531
531
  # be used.
532
532
  # @param [Hash] labels A hash of user-provided labels associated with
@@ -139,8 +139,8 @@ module Google
139
139
  # * `empty` - An error will be returned if the destination table
140
140
  # already contains data.
141
141
  # @param [String] job_id A user-defined ID for the copy job. The ID
142
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
143
- # (_), or dashes (-). The maximum length is 1,024 characters. If
142
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
143
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
144
144
  # `job_id` is provided, then `prefix` will not be used.
145
145
  #
146
146
  # See [Generating a job
@@ -149,8 +149,8 @@ module Google
149
149
  # prepended to a generated value to produce a unique job ID. For
150
150
  # example, the prefix `daily_import_job_` can be given to generate a
151
151
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
152
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
153
- # underscores (_), or dashes (-). The maximum length of the entire ID
152
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
153
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
154
154
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
155
155
  # be used.
156
156
  # @param [Hash] labels A hash of user-provided labels associated with
@@ -291,7 +291,7 @@ module Google
291
291
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql` to
292
292
  # true.
293
293
  #
294
- # Ruby types are mapped to BigQuery types as follows:
294
+ # BigQuery types are converted from Ruby types as follows:
295
295
  #
296
296
  # | BigQuery | Ruby | Notes |
297
297
  # |--------------|--------------------------------------|----------------------------------------------------|
@@ -299,10 +299,11 @@ module Google
299
299
  # | `INT64` | `Integer` | |
300
300
  # | `FLOAT64` | `Float` | |
301
301
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
302
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
302
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`, below.|
303
303
  # | `STRING` | `String` | |
304
304
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
305
305
  # | `DATE` | `Date` | |
306
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
306
307
  # | `TIMESTAMP` | `Time` | |
307
308
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
308
309
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -310,7 +311,8 @@ module Google
310
311
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
311
312
  #
312
313
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
313
- # of each BigQuery data type, including allowed values.
314
+ # of each BigQuery data type, including allowed values. For the `GEOGRAPHY` type, see [Working with BigQuery
315
+ # GIS data](https://cloud.google.com/bigquery/docs/gis-data).
314
316
  # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
315
317
  # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
316
318
  # specify the SQL type for these values.
@@ -327,6 +329,7 @@ module Google
327
329
  # * `:STRING`
328
330
  # * `:DATETIME`
329
331
  # * `:DATE`
332
+ # * `:GEOGRAPHY`
330
333
  # * `:TIMESTAMP`
331
334
  # * `:TIME`
332
335
  # * `:BYTES`
@@ -404,8 +407,8 @@ module Google
404
407
  # (without incurring a charge). Optional. If unspecified, this will be
405
408
  # set to your project default.
406
409
  # @param [String] job_id A user-defined ID for the query job. The ID
407
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
408
- # (_), or dashes (-). The maximum length is 1,024 characters. If
410
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
411
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
409
412
  # `job_id` is provided, then `prefix` will not be used.
410
413
  #
411
414
  # See [Generating a job
@@ -414,8 +417,8 @@ module Google
414
417
  # prepended to a generated value to produce a unique job ID. For
415
418
  # example, the prefix `daily_import_job_` can be given to generate a
416
419
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
417
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
418
- # underscores (_), or dashes (-). The maximum length of the entire ID
420
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
421
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
419
422
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
420
423
  # be used.
421
424
  #
@@ -638,7 +641,7 @@ module Google
638
641
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql` to
639
642
  # true.
640
643
  #
641
- # Ruby types are mapped to BigQuery types as follows:
644
+ # BigQuery types are converted from Ruby types as follows:
642
645
  #
643
646
  # | BigQuery | Ruby | Notes |
644
647
  # |--------------|--------------------------------------|----------------------------------------------------|
@@ -646,10 +649,11 @@ module Google
646
649
  # | `INT64` | `Integer` | |
647
650
  # | `FLOAT64` | `Float` | |
648
651
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
649
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
652
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`, below.|
650
653
  # | `STRING` | `String` | |
651
654
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
652
655
  # | `DATE` | `Date` | |
656
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
653
657
  # | `TIMESTAMP` | `Time` | |
654
658
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
655
659
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -657,7 +661,8 @@ module Google
657
661
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
658
662
  #
659
663
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
660
- # of each BigQuery data type, including allowed values.
664
+ # of each BigQuery data type, including allowed values. For the `GEOGRAPHY` type, see [Working with BigQuery
665
+ # GIS data](https://cloud.google.com/bigquery/docs/gis-data).
661
666
  # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
662
667
  # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
663
668
  # specify the SQL type for these values.
@@ -674,6 +679,7 @@ module Google
674
679
  # * `:STRING`
675
680
  # * `:DATETIME`
676
681
  # * `:DATE`
682
+ # * `:GEOGRAPHY`
677
683
  # * `:TIMESTAMP`
678
684
  # * `:TIME`
679
685
  # * `:BYTES`
@@ -980,8 +986,8 @@ module Google
980
986
  # Creates a new dataset.
981
987
  #
982
988
  # @param [String] dataset_id A unique ID for this dataset, without the
983
- # project name. The ID must contain only letters (a-z, A-Z), numbers
984
- # (0-9), or underscores (_). The maximum length is 1,024 characters.
989
+ # project name. The ID must contain only letters (`[A-Za-z]`), numbers
990
+ # (`[0-9]`), or underscores (`_`). The maximum length is 1,024 characters.
985
991
  # @param [String] name A descriptive name for the dataset.
986
992
  # @param [String] description A user-friendly description of the
987
993
  # dataset.
@@ -1518,8 +1524,8 @@ module Google
1518
1524
  # @param [Boolean] header Whether to print out a header row in table
1519
1525
  # exports. Default is `true`. Not applicable when extracting models.
1520
1526
  # @param [String] job_id A user-defined ID for the extract job. The ID
1521
- # must contain only letters (a-z, A-Z), numbers (0-9), underscores
1522
- # (_), or dashes (-). The maximum length is 1,024 characters. If
1527
+ # must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), underscores
1528
+ # (`_`), or dashes (`-`). The maximum length is 1,024 characters. If
1523
1529
  # `job_id` is provided, then `prefix` will not be used.
1524
1530
  #
1525
1531
  # See [Generating a job
@@ -1528,8 +1534,8 @@ module Google
1528
1534
  # prepended to a generated value to produce a unique job ID. For
1529
1535
  # example, the prefix `daily_import_job_` can be given to generate a
1530
1536
  # job ID such as `daily_import_job_12vEDtMQ0mbp1Mo5Z7mzAFQJZazh`. The
1531
- # prefix must contain only letters (a-z, A-Z), numbers (0-9),
1532
- # underscores (_), or dashes (-). The maximum length of the entire ID
1537
+ # prefix must contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
1538
+ # underscores (`_`), or dashes (`-`). The maximum length of the entire ID
1533
1539
  # is 1,024 characters. If `job_id` is provided, then `prefix` will not
1534
1540
  # be used.
1535
1541
  # @param [Hash] labels A hash of user-provided labels associated with
@@ -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
  #
@@ -858,7 +891,7 @@ module Google
858
891
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql`
859
892
  # to true.
860
893
  #
861
- # Ruby types are mapped to BigQuery types as follows:
894
+ # BigQuery types are converted from Ruby types as follows:
862
895
  #
863
896
  # | BigQuery | Ruby | Notes |
864
897
  # |--------------|--------------------------------------|--------------------------------------------------|
@@ -866,10 +899,11 @@ module Google
866
899
  # | `INT64` | `Integer` | |
867
900
  # | `FLOAT64` | `Float` | |
868
901
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
869
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
902
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`. |
870
903
  # | `STRING` | `String` | |
871
904
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
872
905
  # | `DATE` | `Date` | |
906
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`. |
873
907
  # | `TIMESTAMP` | `Time` | |
874
908
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
875
909
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -877,7 +911,8 @@ module Google
877
911
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
878
912
  #
879
913
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
880
- # of each BigQuery data type, including allowed values.
914
+ # of each BigQuery data type, including allowed values. For the `GEOGRAPHY` type, see [Working with BigQuery
915
+ # GIS data](https://cloud.google.com/bigquery/docs/gis-data).
881
916
  #
882
917
  # @!group Attributes
883
918
  def params= params
@@ -893,7 +928,7 @@ module Google
893
928
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql`
894
929
  # to true.
895
930
  #
896
- # Ruby types are mapped to BigQuery types as follows:
931
+ # BigQuery types are converted from Ruby types as follows:
897
932
  #
898
933
  # | BigQuery | Ruby | Notes |
899
934
  # |--------------|--------------------------------------|--------------------------------------------------|
@@ -901,10 +936,11 @@ module Google
901
936
  # | `INT64` | `Integer` | |
902
937
  # | `FLOAT64` | `Float` | |
903
938
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
904
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
939
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`. |
905
940
  # | `STRING` | `String` | |
906
941
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
907
942
  # | `DATE` | `Date` | |
943
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`. |
908
944
  # | `TIMESTAMP` | `Time` | |
909
945
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
910
946
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -912,7 +948,8 @@ module Google
912
948
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
913
949
  #
914
950
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
915
- # of each BigQuery data type, including allowed values.
951
+ # of each BigQuery data type, including allowed values. For the `GEOGRAPHY` type, see [Working with BigQuery
952
+ # GIS data](https://cloud.google.com/bigquery/docs/gis-data).
916
953
  # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
917
954
  # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
918
955
  # specify the SQL type for these values.
@@ -929,6 +966,7 @@ module Google
929
966
  # * `:STRING`
930
967
  # * `:DATETIME`
931
968
  # * `:DATE`
969
+ # * `:GEOGRAPHY`
932
970
  # * `:TIMESTAMP`
933
971
  # * `:TIME`
934
972
  # * `:BYTES`
@@ -116,8 +116,8 @@ module Google
116
116
  ##
117
117
  # A unique ID for this routine, without the project name.
118
118
  #
119
- # @return [String] The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum
120
- # length is 256 characters.
119
+ # @return [String] The ID must contain only letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`). The
120
+ # maximum length is 256 characters.
121
121
  #
122
122
  # @!group Attributes
123
123
  #
@@ -40,14 +40,31 @@ module Google
40
40
  MODES = ["NULLABLE", "REQUIRED", "REPEATED"].freeze
41
41
 
42
42
  # @private
43
- TYPES = ["STRING", "INTEGER", "INT64", "FLOAT", "FLOAT64", "NUMERIC", "BIGNUMERIC", "BOOLEAN", "BOOL",
44
- "BYTES", "TIMESTAMP", "TIME", "DATETIME", "DATE", "RECORD", "STRUCT"].freeze
43
+ TYPES = [
44
+ "BIGNUMERIC",
45
+ "BOOL",
46
+ "BOOLEAN",
47
+ "BYTES",
48
+ "DATE",
49
+ "DATETIME",
50
+ "FLOAT",
51
+ "FLOAT64",
52
+ "GEOGRAPHY",
53
+ "INTEGER",
54
+ "INT64",
55
+ "NUMERIC",
56
+ "RECORD",
57
+ "STRING",
58
+ "STRUCT",
59
+ "TIME",
60
+ "TIMESTAMP"
61
+ ].freeze
45
62
 
46
63
  ##
47
64
  # The name of the field.
48
65
  #
49
66
  # @return [String] The field name. The name must contain only
50
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
67
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
51
68
  # start with a letter or underscore. The maximum length is 128
52
69
  # characters.
53
70
  #
@@ -59,7 +76,7 @@ module Google
59
76
  # Updates the name of the field.
60
77
  #
61
78
  # @param [String] new_name The field name. The name must contain only
62
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
79
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
63
80
  # start with a letter or underscore. The maximum length is 128
64
81
  # characters.
65
82
  #
@@ -70,12 +87,25 @@ module Google
70
87
  ##
71
88
  # The data type of the field.
72
89
  #
73
- # @return [String] The field data type. Possible values include
74
- # `STRING`, `BYTES`, `INTEGER`, `INT64` (same as `INTEGER`),
75
- # `FLOAT`, `FLOAT64` (same as `FLOAT`), `NUMERIC`, `BIGNUMERIC`,
76
- # `BOOLEAN`, `BOOL` (same as `BOOLEAN`), `TIMESTAMP`, `DATE`,
77
- # `TIME`, `DATETIME`, `RECORD` (where `RECORD` indicates that the
78
- # field contains a nested schema) or `STRUCT` (same as `RECORD`).
90
+ # @return [String] The field data type. Possible values include:
91
+ #
92
+ # * `BIGNUMERIC`
93
+ # * `BOOL`
94
+ # * `BOOLEAN` (same as `BOOL`)
95
+ # * `BYTES`
96
+ # * `DATE`
97
+ # * `DATETIME`
98
+ # * `FLOAT`
99
+ # * `FLOAT64` (same as `FLOAT`)
100
+ # * `GEOGRAPHY`
101
+ # * `INTEGER`
102
+ # * `INT64` (same as `INTEGER`)
103
+ # * `NUMERIC`
104
+ # * `RECORD` (where `RECORD` indicates that the field contains a nested schema)
105
+ # * `STRING`
106
+ # * `STRUCT` (same as `RECORD`)
107
+ # * `TIME`
108
+ # * `TIMESTAMP`
79
109
  #
80
110
  def type
81
111
  @gapi.type
@@ -84,12 +114,25 @@ module Google
84
114
  ##
85
115
  # Updates the data type of the field.
86
116
  #
87
- # @param [String] new_type The data type. Possible values include
88
- # `STRING`, `BYTES`, `INTEGER`, `INT64` (same as `INTEGER`),
89
- # `FLOAT`, `FLOAT64` (same as `FLOAT`), `NUMERIC`, `BIGNUMERIC`,
90
- # `BOOLEAN`, `BOOL` (same as `BOOLEAN`), `TIMESTAMP`, `DATE`,
91
- # `TIME`, `DATETIME`, `RECORD` (where `RECORD` indicates that the
92
- # field contains a nested schema) or `STRUCT` (same as `RECORD`).
117
+ # @param [String] new_type The data type. Possible values include:
118
+ #
119
+ # * `BIGNUMERIC`
120
+ # * `BOOL`
121
+ # * `BOOLEAN` (same as `BOOL`)
122
+ # * `BYTES`
123
+ # * `DATE`
124
+ # * `DATETIME`
125
+ # * `FLOAT`
126
+ # * `FLOAT64` (same as `FLOAT`)
127
+ # * `GEOGRAPHY`
128
+ # * `INTEGER`
129
+ # * `INT64` (same as `INTEGER`)
130
+ # * `NUMERIC`
131
+ # * `RECORD` (where `RECORD` indicates that the field contains a nested schema)
132
+ # * `STRING`
133
+ # * `STRUCT` (same as `RECORD`)
134
+ # * `TIME`
135
+ # * `TIMESTAMP`
93
136
  #
94
137
  def type= new_type
95
138
  @gapi.update! type: verify_type(new_type)
@@ -163,6 +206,101 @@ module Google
163
206
  @gapi.update! mode: verify_mode(new_mode)
164
207
  end
165
208
 
209
+ ##
210
+ # The policy tag list for the field. Policy tag identifiers are of the form
211
+ # `projects/*/locations/*/taxonomies/*/policyTags/*`. At most 1 policy tag
212
+ # is currently allowed.
213
+ #
214
+ # @see https://cloud.google.com/bigquery/docs/column-level-security-intro
215
+ # Introduction to BigQuery column-level security
216
+ #
217
+ # @return [Array<String>, nil] The policy tag list for the field, or `nil`.
218
+ #
219
+ # @example
220
+ # require "google/cloud/bigquery"
221
+ #
222
+ # bigquery = Google::Cloud::Bigquery.new
223
+ # dataset = bigquery.dataset "my_dataset"
224
+ # table = dataset.table "my_table"
225
+ #
226
+ # table.schema.field("age").policy_tags
227
+ #
228
+ def policy_tags
229
+ names = @gapi.policy_tags&.names
230
+ names.to_a if names && !names.empty?
231
+ end
232
+
233
+ ##
234
+ # Updates the policy tag list for the field.
235
+ #
236
+ # @see https://cloud.google.com/bigquery/docs/column-level-security-intro
237
+ # Introduction to BigQuery column-level security
238
+ #
239
+ # @param [Array<String>, String, nil] new_policy_tags The policy tag list or
240
+ # single policy tag for the field, or `nil` to remove the existing policy tags.
241
+ # Policy tag identifiers are of the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
242
+ # At most 1 policy tag is currently allowed.
243
+ #
244
+ # @example
245
+ # require "google/cloud/bigquery"
246
+ #
247
+ # bigquery = Google::Cloud::Bigquery.new
248
+ # dataset = bigquery.dataset "my_dataset"
249
+ # table = dataset.table "my_table"
250
+ #
251
+ # policy_tag = "projects/my-project/locations/us/taxonomies/my-taxonomy/policyTags/my-policy-tag"
252
+ # table.schema do |schema|
253
+ # schema.field("age").policy_tags = policy_tag
254
+ # end
255
+ #
256
+ # table.schema.field("age").policy_tags
257
+ #
258
+ def policy_tags= new_policy_tags
259
+ # If new_policy_tags is nil, send an empty array.
260
+ # Sending a nil value for policy_tags results in no change.
261
+ new_policy_tags = Array(new_policy_tags)
262
+ policy_tag_list = Google::Apis::BigqueryV2::TableFieldSchema::PolicyTags.new names: new_policy_tags
263
+ @gapi.update! policy_tags: policy_tag_list
264
+ end
265
+
266
+ ##
267
+ # The maximum length of values of this field for {#string?} or {bytes?} fields. If `max_length` is not
268
+ # specified, no maximum length constraint is imposed on this field. If type = `STRING`, then `max_length`
269
+ # represents the maximum UTF-8 length of strings in this field. If type = `BYTES`, then `max_length`
270
+ # represents the maximum number of bytes in this field.
271
+ #
272
+ # @return [Integer, nil] The maximum length of values of this field, or `nil`.
273
+ #
274
+ def max_length
275
+ @gapi.max_length
276
+ end
277
+
278
+ ##
279
+ # The precision (maximum number of total digits) for `NUMERIC` or `BIGNUMERIC` types. For {#numeric?} fields,
280
+ # acceptable values for precision must be `1 ≤ (precision - scale) ≤ 29` and values for scale must be `0 ≤
281
+ # scale ≤ 9`. For {#bignumeric?} fields, acceptable values for precision must be `1 ≤ (precision - scale) ≤
282
+ # 38` and values for scale must be `0 ≤ scale ≤ 38`. If the scale value is set, the precision value must be
283
+ # set as well.
284
+ #
285
+ # @return [Integer, nil] The precision for the field, or `nil`.
286
+ #
287
+ def precision
288
+ @gapi.precision
289
+ end
290
+
291
+ ##
292
+ # The scale (maximum number of digits in the fractional part) for `NUMERIC` or `BIGNUMERIC` types. For
293
+ # {#numeric?} fields, acceptable values for precision must be `1 ≤ (precision - scale) ≤ 29` and values for
294
+ # scale must be `0 ≤ scale ≤ 9`. For {#bignumeric?} fields, acceptable values for precision must be `1 ≤
295
+ # (precision - scale) ≤ 38` and values for scale must be `0 ≤ scale ≤ 38`. If the scale value is set, the
296
+ # precision value must be set as well.
297
+ #
298
+ # @return [Integer, nil] The scale for the field, or `nil`.
299
+ #
300
+ def scale
301
+ @gapi.scale
302
+ end
303
+
166
304
  ##
167
305
  # Checks if the type of the field is `STRING`.
168
306
  #
@@ -262,6 +400,15 @@ module Google
262
400
  type == "DATE"
263
401
  end
264
402
 
403
+ ##
404
+ # Checks if the type of the field is `GEOGRAPHY`.
405
+ #
406
+ # @return [Boolean] `true` when `GEOGRAPHY`, `false` otherwise.
407
+ #
408
+ def geography?
409
+ type == "GEOGRAPHY"
410
+ end
411
+
265
412
  ##
266
413
  # Checks if the type of the field is `RECORD`.
267
414
  #
@@ -348,18 +495,29 @@ module Google
348
495
  # This can only be called on fields that are of type `RECORD`.
349
496
  #
350
497
  # @param [String] name The field name. The name must contain only
351
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
498
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
352
499
  # start with a letter or underscore. The maximum length is 128
353
500
  # characters.
354
501
  # @param [String] description A description of the field.
355
502
  # @param [Symbol] mode The field's mode. The possible values are
356
503
  # `:nullable`, `:required`, and `:repeated`. The default value is
357
504
  # `:nullable`.
358
- #
359
- def string name, description: nil, mode: :nullable
505
+ # @param [Array<String>, String] policy_tags The policy tag list or
506
+ # single policy tag for the field. Policy tag identifiers are of
507
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
508
+ # At most 1 policy tag is currently allowed.
509
+ # @param [Integer] max_length The maximum UTF-8 length of strings
510
+ # allowed in the field.
511
+ #
512
+ def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
360
513
  record_check!
361
514
 
362
- add_field name, :string, description: description, mode: mode
515
+ add_field name,
516
+ :string,
517
+ description: description,
518
+ mode: mode,
519
+ policy_tags: policy_tags,
520
+ max_length: max_length
363
521
  end
364
522
 
365
523
  ##
@@ -368,18 +526,22 @@ module Google
368
526
  # This can only be called on fields that are of type `RECORD`.
369
527
  #
370
528
  # @param [String] name The field name. The name must contain only
371
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
529
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
372
530
  # start with a letter or underscore. The maximum length is 128
373
531
  # characters.
374
532
  # @param [String] description A description of the field.
375
533
  # @param [Symbol] mode The field's mode. The possible values are
376
534
  # `:nullable`, `:required`, and `:repeated`. The default value is
377
535
  # `:nullable`.
536
+ # @param [Array<String>, String] policy_tags The policy tag list or
537
+ # single policy tag for the field. Policy tag identifiers are of
538
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
539
+ # At most 1 policy tag is currently allowed.
378
540
  #
379
- def integer name, description: nil, mode: :nullable
541
+ def integer name, description: nil, mode: :nullable, policy_tags: nil
380
542
  record_check!
381
543
 
382
- add_field name, :integer, description: description, mode: mode
544
+ add_field name, :integer, description: description, mode: mode, policy_tags: policy_tags
383
545
  end
384
546
 
385
547
  ##
@@ -389,18 +551,22 @@ module Google
389
551
  # This can only be called on fields that are of type `RECORD`.
390
552
  #
391
553
  # @param [String] name The field name. The name must contain only
392
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
554
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
393
555
  # start with a letter or underscore. The maximum length is 128
394
556
  # characters.
395
557
  # @param [String] description A description of the field.
396
558
  # @param [Symbol] mode The field's mode. The possible values are
397
559
  # `:nullable`, `:required`, and `:repeated`. The default value is
398
560
  # `:nullable`.
561
+ # @param [Array<String>, String] policy_tags The policy tag list or
562
+ # single policy tag for the field. Policy tag identifiers are of
563
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
564
+ # At most 1 policy tag is currently allowed.
399
565
  #
400
- def float name, description: nil, mode: :nullable
566
+ def float name, description: nil, mode: :nullable, policy_tags: nil
401
567
  record_check!
402
568
 
403
- add_field name, :float, description: description, mode: mode
569
+ add_field name, :float, description: description, mode: mode, policy_tags: policy_tags
404
570
  end
405
571
 
406
572
  ##
@@ -420,18 +586,38 @@ module Google
420
586
  # This can only be called on fields that are of type `RECORD`.
421
587
  #
422
588
  # @param [String] name The field name. The name must contain only
423
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
589
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
424
590
  # start with a letter or underscore. The maximum length is 128
425
591
  # characters.
426
592
  # @param [String] description A description of the field.
427
593
  # @param [Symbol] mode The field's mode. The possible values are
428
594
  # `:nullable`, `:required`, and `:repeated`. The default value is
429
595
  # `:nullable`.
430
- #
431
- def numeric name, description: nil, mode: :nullable
596
+ # @param [Array<String>, String] policy_tags The policy tag list or
597
+ # single policy tag for the field. Policy tag identifiers are of
598
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
599
+ # At most 1 policy tag is currently allowed.
600
+ # @param [Integer] precision The precision (maximum number of total
601
+ # digits) for the field. Acceptable values for precision must be:
602
+ # `1 ≤ (precision - scale) ≤ 29`. Values for scale must be:
603
+ # `0 ≤ scale ≤ 9`. If the scale value is set, the precision value
604
+ # must be set as well.
605
+ # @param [Integer] scale The scale (maximum number of digits in the
606
+ # fractional part) for the field. Acceptable values for precision
607
+ # must be: `1 ≤ (precision - scale) ≤ 29`. Values for scale must
608
+ # be: `0 ≤ scale ≤ 9`. If the scale value is set, the precision
609
+ # value must be set as well.
610
+ #
611
+ def numeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
432
612
  record_check!
433
613
 
434
- add_field name, :numeric, description: description, mode: mode
614
+ add_field name,
615
+ :numeric,
616
+ description: description,
617
+ mode: mode,
618
+ policy_tags: policy_tags,
619
+ precision: precision,
620
+ scale: scale
435
621
  end
436
622
 
437
623
  ##
@@ -451,18 +637,38 @@ module Google
451
637
  # This can only be called on fields that are of type `RECORD`.
452
638
  #
453
639
  # @param [String] name The field name. The name must contain only
454
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
640
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
455
641
  # start with a letter or underscore. The maximum length is 128
456
642
  # characters.
457
643
  # @param [String] description A description of the field.
458
644
  # @param [Symbol] mode The field's mode. The possible values are
459
645
  # `:nullable`, `:required`, and `:repeated`. The default value is
460
646
  # `:nullable`.
461
- #
462
- def bignumeric name, description: nil, mode: :nullable
647
+ # @param [Array<String>, String] policy_tags The policy tag list or
648
+ # single policy tag for the field. Policy tag identifiers are of
649
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
650
+ # At most 1 policy tag is currently allowed.
651
+ # @param [Integer] precision The precision (maximum number of total
652
+ # digits) for the field. Acceptable values for precision must be:
653
+ # `1 ≤ (precision - scale) ≤ 38`. Values for scale must be:
654
+ # `0 ≤ scale ≤ 38`. If the scale value is set, the precision value
655
+ # must be set as well.
656
+ # @param [Integer] scale The scale (maximum number of digits in the
657
+ # fractional part) for the field. Acceptable values for precision
658
+ # must be: `1 ≤ (precision - scale) ≤ 38`. Values for scale must
659
+ # be: `0 ≤ scale ≤ 38`. If the scale value is set, the precision
660
+ # value must be set as well.
661
+ #
662
+ def bignumeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
463
663
  record_check!
464
664
 
465
- add_field name, :bignumeric, description: description, mode: mode
665
+ add_field name,
666
+ :bignumeric,
667
+ description: description,
668
+ mode: mode,
669
+ policy_tags: policy_tags,
670
+ precision: precision,
671
+ scale: scale
466
672
  end
467
673
 
468
674
  ##
@@ -471,18 +677,22 @@ module Google
471
677
  # This can only be called on fields that are of type `RECORD`.
472
678
  #
473
679
  # @param [String] name The field name. The name must contain only
474
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
680
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
475
681
  # start with a letter or underscore. The maximum length is 128
476
682
  # characters.
477
683
  # @param [String] description A description of the field.
478
684
  # @param [Symbol] mode The field's mode. The possible values are
479
685
  # `:nullable`, `:required`, and `:repeated`. The default value is
480
686
  # `:nullable`.
687
+ # @param [Array<String>, String] policy_tags The policy tag list or
688
+ # single policy tag for the field. Policy tag identifiers are of
689
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
690
+ # At most 1 policy tag is currently allowed.
481
691
  #
482
- def boolean name, description: nil, mode: :nullable
692
+ def boolean name, description: nil, mode: :nullable, policy_tags: nil
483
693
  record_check!
484
694
 
485
- add_field name, :boolean, description: description, mode: mode
695
+ add_field name, :boolean, description: description, mode: mode, policy_tags: policy_tags
486
696
  end
487
697
 
488
698
  ##
@@ -491,18 +701,29 @@ module Google
491
701
  # This can only be called on fields that are of type `RECORD`.
492
702
  #
493
703
  # @param [String] name The field name. The name must contain only
494
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
704
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
495
705
  # start with a letter or underscore. The maximum length is 128
496
706
  # characters.
497
707
  # @param [String] description A description of the field.
498
708
  # @param [Symbol] mode The field's mode. The possible values are
499
709
  # `:nullable`, `:required`, and `:repeated`. The default value is
500
710
  # `:nullable`.
501
- #
502
- def bytes name, description: nil, mode: :nullable
711
+ # @param [Array<String>, String] policy_tags The policy tag list or
712
+ # single policy tag for the field. Policy tag identifiers are of
713
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
714
+ # At most 1 policy tag is currently allowed.
715
+ # @param [Integer] max_length The maximum the maximum number of
716
+ # bytes in the field.
717
+ #
718
+ def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
503
719
  record_check!
504
720
 
505
- add_field name, :bytes, description: description, mode: mode
721
+ add_field name,
722
+ :bytes,
723
+ description: description,
724
+ mode: mode,
725
+ policy_tags: policy_tags,
726
+ max_length: max_length
506
727
  end
507
728
 
508
729
  ##
@@ -511,18 +732,22 @@ module Google
511
732
  # This can only be called on fields that are of type `RECORD`.
512
733
  #
513
734
  # @param [String] name The field name. The name must contain only
514
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
735
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
515
736
  # start with a letter or underscore. The maximum length is 128
516
737
  # characters.
517
738
  # @param [String] description A description of the field.
518
739
  # @param [Symbol] mode The field's mode. The possible values are
519
740
  # `:nullable`, `:required`, and `:repeated`. The default value is
520
741
  # `:nullable`.
742
+ # @param [Array<String>, String] policy_tags The policy tag list or
743
+ # single policy tag for the field. Policy tag identifiers are of
744
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
745
+ # At most 1 policy tag is currently allowed.
521
746
  #
522
- def timestamp name, description: nil, mode: :nullable
747
+ def timestamp name, description: nil, mode: :nullable, policy_tags: nil
523
748
  record_check!
524
749
 
525
- add_field name, :timestamp, description: description, mode: mode
750
+ add_field name, :timestamp, description: description, mode: mode, policy_tags: policy_tags
526
751
  end
527
752
 
528
753
  ##
@@ -531,18 +756,22 @@ module Google
531
756
  # This can only be called on fields that are of type `RECORD`.
532
757
  #
533
758
  # @param [String] name The field name. The name must contain only
534
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
759
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
535
760
  # start with a letter or underscore. The maximum length is 128
536
761
  # characters.
537
762
  # @param [String] description A description of the field.
538
763
  # @param [Symbol] mode The field's mode. The possible values are
539
764
  # `:nullable`, `:required`, and `:repeated`. The default value is
540
765
  # `:nullable`.
766
+ # @param [Array<String>, String] policy_tags The policy tag list or
767
+ # single policy tag for the field. Policy tag identifiers are of
768
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
769
+ # At most 1 policy tag is currently allowed.
541
770
  #
542
- def time name, description: nil, mode: :nullable
771
+ def time name, description: nil, mode: :nullable, policy_tags: nil
543
772
  record_check!
544
773
 
545
- add_field name, :time, description: description, mode: mode
774
+ add_field name, :time, description: description, mode: mode, policy_tags: policy_tags
546
775
  end
547
776
 
548
777
  ##
@@ -551,18 +780,22 @@ module Google
551
780
  # This can only be called on fields that are of type `RECORD`.
552
781
  #
553
782
  # @param [String] name The field name. The name must contain only
554
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
783
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
555
784
  # start with a letter or underscore. The maximum length is 128
556
785
  # characters.
557
786
  # @param [String] description A description of the field.
558
787
  # @param [Symbol] mode The field's mode. The possible values are
559
788
  # `:nullable`, `:required`, and `:repeated`. The default value is
560
789
  # `:nullable`.
790
+ # @param [Array<String>, String] policy_tags The policy tag list or
791
+ # single policy tag for the field. Policy tag identifiers are of
792
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
793
+ # At most 1 policy tag is currently allowed.
561
794
  #
562
- def datetime name, description: nil, mode: :nullable
795
+ def datetime name, description: nil, mode: :nullable, policy_tags: nil
563
796
  record_check!
564
797
 
565
- add_field name, :datetime, description: description, mode: mode
798
+ add_field name, :datetime, description: description, mode: mode, policy_tags: policy_tags
566
799
  end
567
800
 
568
801
  ##
@@ -571,18 +804,46 @@ module Google
571
804
  # This can only be called on fields that are of type `RECORD`.
572
805
  #
573
806
  # @param [String] name The field name. The name must contain only
574
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
807
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
575
808
  # start with a letter or underscore. The maximum length is 128
576
809
  # characters.
577
810
  # @param [String] description A description of the field.
578
811
  # @param [Symbol] mode The field's mode. The possible values are
579
812
  # `:nullable`, `:required`, and `:repeated`. The default value is
580
813
  # `:nullable`.
814
+ # @param [Array<String>, String] policy_tags The policy tag list or
815
+ # single policy tag for the field. Policy tag identifiers are of
816
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
817
+ # At most 1 policy tag is currently allowed.
581
818
  #
582
- def date name, description: nil, mode: :nullable
819
+ def date name, description: nil, mode: :nullable, policy_tags: nil
583
820
  record_check!
584
821
 
585
- add_field name, :date, description: description, mode: mode
822
+ add_field name, :date, description: description, mode: mode, policy_tags: policy_tags
823
+ end
824
+
825
+ ##
826
+ # Adds a geography field to the nested schema of a record field.
827
+ #
828
+ # @see https://cloud.google.com/bigquery/docs/gis-data Working with BigQuery GIS data
829
+ #
830
+ # @param [String] name The field name. The name must contain only
831
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
832
+ # start with a letter or underscore. The maximum length is 128
833
+ # characters.
834
+ # @param [String] description A description of the field.
835
+ # @param [Symbol] mode The field's mode. The possible values are
836
+ # `:nullable`, `:required`, and `:repeated`. The default value is
837
+ # `:nullable`.
838
+ # @param [Array<String>, String] policy_tags The policy tag list or
839
+ # single policy tag for the field. Policy tag identifiers are of
840
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
841
+ # At most 1 policy tag is currently allowed.
842
+ #
843
+ def geography name, description: nil, mode: :nullable, policy_tags: nil
844
+ record_check!
845
+
846
+ add_field name, :geography, description: description, mode: mode, policy_tags: policy_tags
586
847
  end
587
848
 
588
849
  ##
@@ -594,7 +855,7 @@ module Google
594
855
  # This can only be called on fields that are of type `RECORD`.
595
856
  #
596
857
  # @param [String] name The field name. The name must contain only
597
- # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
858
+ # letters (`[A-Za-z]`), numbers (`[0-9]`), or underscores (`_`), and must
598
859
  # start with a letter or underscore. The maximum length is 128
599
860
  # characters.
600
861
  # @param [String] description A description of the field.
@@ -678,7 +939,7 @@ module Google
678
939
  "Cannot add fields to a non-RECORD field (#{type})"
679
940
  end
680
941
 
681
- def add_field name, type, description: nil, mode: :nullable
942
+ def add_field name, type, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
682
943
  frozen_check!
683
944
 
684
945
  new_gapi = Google::Apis::BigqueryV2::TableFieldSchema.new(
@@ -688,7 +949,11 @@ module Google
688
949
  mode: verify_mode(mode),
689
950
  fields: []
690
951
  )
691
-
952
+ if policy_tags
953
+ policy_tags = Array(policy_tags)
954
+ new_gapi.policy_tags = Google::Apis::BigqueryV2::TableFieldSchema::PolicyTags.new names: policy_tags
955
+ end
956
+ new_gapi.max_length = max_length if max_length
692
957
  # Remove any existing field of this name
693
958
  @gapi.fields ||= []
694
959
  @gapi.fields.reject! { |f| f.name == new_gapi.name }