google-cloud-bigquery 1.34.0 → 1.35.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1868b74a16bb2b5b53c861f461c684bb5926e71c9c273a4d8f3bad9a02502a2
4
- data.tar.gz: 582047d7174dc4063b0f9aaee2057136b4aff4eda687c05c2e9a931ba9dfc5b8
3
+ metadata.gz: 403979ca0fcee3fa41911b46cd53f9f5c4f030f85610c29870fc770f41de7d03
4
+ data.tar.gz: 15060d2d7351dc8e922adf77483c48ee4be7acf98bffdcb824f699920db65d7c
5
5
  SHA512:
6
- metadata.gz: f4aaf252e3277bb47e9b1c27a083da4d74a3f37064506b7d288cc1f9dc720906d0403712917d1d8ada4fb5cef08e43a5f7db297848f428a007f197513fd4c72e
7
- data.tar.gz: 42c4c862b05fbf0563bdb0721685dab1651243ceb5a803cbf6000b42203be58a5ac4504d4b7d0da9864825c041c379cd344c0efdd309bfb4aa5c7914de92fafd
6
+ metadata.gz: 6bdcdd87c1fb4dcafdb8a071fe21322fc45c3ac94a3a89617d2a576f15733e371833ee47027056081af955e7366a817aaab3eead234d1ed2098678e6ca5e225e
7
+ data.tar.gz: c46e7b144f15072b10fe16bff3ccffdc54f43801a59f6760666c3cc2c2d8b8230262163de8dadb0f705271d7b27700abe1703f39fd26cd9b97d3fdd442379e61
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Release History
2
2
 
3
+ ### 1.35.0 / 2021-08-12
4
+
5
+ #### Features
6
+
7
+ * Add GEOGRAPHY schema helpers
8
+ * Add LoadJob#geography
9
+ * Add Schema::Field#geography
10
+ * Add Table::Updater#geography
11
+ * Add support for GEOGRAPHY type
12
+ * Add Schema#geography
13
+ * Add support for multistatement transaction statistics in jobs
14
+ * Add Job#transaction_id
15
+
3
16
  ### 1.34.0 / 2021-07-20
4
17
 
5
18
  #### Features
@@ -38,6 +38,7 @@ module Google
38
38
  # | `STRING` | `String` | |
39
39
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
40
40
  # | `DATE` | `Date` | |
41
+ # | `GEOGRAPHY` | `String` | |
41
42
  # | `TIMESTAMP` | `Time` | |
42
43
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
43
44
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -102,6 +103,8 @@ module Google
102
103
  ::Time.parse("#{value[:v]} UTC").to_datetime
103
104
  elsif field.type == "DATE"
104
105
  Date.parse value[:v]
106
+ elsif field.type == "GEOGRAPHY"
107
+ String value[:v]
105
108
  else
106
109
  value[:v]
107
110
  end
@@ -1138,7 +1138,7 @@ module Google
1138
1138
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql` to
1139
1139
  # true.
1140
1140
  #
1141
- # Ruby types are mapped to BigQuery types as follows:
1141
+ # BigQuery types are converted from Ruby types as follows:
1142
1142
  #
1143
1143
  # | BigQuery | Ruby | Notes |
1144
1144
  # |--------------|--------------------------------------|----------------------------------------------------|
@@ -1146,10 +1146,11 @@ module Google
1146
1146
  # | `INT64` | `Integer` | |
1147
1147
  # | `FLOAT64` | `Float` | |
1148
1148
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
1149
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
1149
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`, below.|
1150
1150
  # | `STRING` | `String` | |
1151
1151
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1152
1152
  # | `DATE` | `Date` | |
1153
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
1153
1154
  # | `TIMESTAMP` | `Time` | |
1154
1155
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1155
1156
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -1157,7 +1158,8 @@ module Google
1157
1158
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
1158
1159
  #
1159
1160
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
1160
- # of each BigQuery data type, including allowed values.
1161
+ # of each BigQuery data type, including allowed values. For the `GEOGRAPHY` type, see [Working with BigQuery
1162
+ # GIS data](https://cloud.google.com/bigquery/docs/gis-data).
1161
1163
  # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
1162
1164
  # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
1163
1165
  # specify the SQL type for these values.
@@ -1174,6 +1176,7 @@ module Google
1174
1176
  # * `:STRING`
1175
1177
  # * `:DATETIME`
1176
1178
  # * `:DATE`
1179
+ # * `:GEOGRAPHY`
1177
1180
  # * `:TIMESTAMP`
1178
1181
  # * `:TIME`
1179
1182
  # * `:BYTES`
@@ -1481,7 +1484,7 @@ module Google
1481
1484
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql` to
1482
1485
  # true.
1483
1486
  #
1484
- # Ruby types are mapped to BigQuery types as follows:
1487
+ # BigQuery types are converted from Ruby types as follows:
1485
1488
  #
1486
1489
  # | BigQuery | Ruby | Notes |
1487
1490
  # |--------------|--------------------------------------|----------------------------------------------------|
@@ -1489,10 +1492,11 @@ module Google
1489
1492
  # | `INT64` | `Integer` | |
1490
1493
  # | `FLOAT64` | `Float` | |
1491
1494
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
1492
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
1495
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`, below.|
1493
1496
  # | `STRING` | `String` | |
1494
1497
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
1495
1498
  # | `DATE` | `Date` | |
1499
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`, below.|
1496
1500
  # | `TIMESTAMP` | `Time` | |
1497
1501
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
1498
1502
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -1500,7 +1504,8 @@ module Google
1500
1504
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
1501
1505
  #
1502
1506
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
1503
- # of each BigQuery data type, including allowed values.
1507
+ # of each BigQuery data type, including allowed values. For the `GEOGRAPHY` type, see [Working with BigQuery
1508
+ # GIS data](https://cloud.google.com/bigquery/docs/gis-data).
1504
1509
  # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
1505
1510
  # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
1506
1511
  # specify the SQL type for these values.
@@ -1517,6 +1522,7 @@ module Google
1517
1522
  # * `:STRING`
1518
1523
  # * `:DATETIME`
1519
1524
  # * `:DATE`
1525
+ # * `:GEOGRAPHY`
1520
1526
  # * `:TIMESTAMP`
1521
1527
  # * `:TIME`
1522
1528
  # * `:BYTES`
@@ -2421,6 +2427,7 @@ module Google
2421
2427
  # | `BIGNUMERIC` | `String` | Pass as `String` to avoid rounding to scale 9. |
2422
2428
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
2423
2429
  # | `DATE` | `Date` | |
2430
+ # | `GEOGRAPHY` | `String` | |
2424
2431
  # | `TIMESTAMP` | `Time` | |
2425
2432
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
2426
2433
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -226,6 +226,15 @@ module Google
226
226
  Array(@gapi.statistics.reservation_usage).map { |g| ReservationUsage.from_gapi g }
227
227
  end
228
228
 
229
+ ##
230
+ # The ID of a multi-statement transaction.
231
+ #
232
+ # @return [String, nil] The transaction ID, or `nil` if not associated with a transaction.
233
+ #
234
+ def transaction_id
235
+ @gapi.statistics.transaction_info&.transaction_id
236
+ end
237
+
229
238
  ##
230
239
  # The statistics including stack frames for a child job of a script.
231
240
  #
@@ -1146,6 +1146,42 @@ module Google
1146
1146
  schema.date name, description: description, mode: mode, policy_tags: policy_tags
1147
1147
  end
1148
1148
 
1149
+ ##
1150
+ # Adds a geography field to the schema.
1151
+ #
1152
+ # See {Schema#geography}.
1153
+ #
1154
+ # @see https://cloud.google.com/bigquery/docs/gis-data Working with BigQuery GIS data
1155
+ #
1156
+ # @param [String] name The field name. The name must contain only
1157
+ # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
1158
+ # start with a letter or underscore. The maximum length is 128
1159
+ # characters.
1160
+ # @param [String] description A description of the field.
1161
+ # @param [Symbol] mode The field's mode. The possible values are
1162
+ # `:nullable`, `:required`, and `:repeated`. The default value is
1163
+ # `:nullable`.
1164
+ # @param [Array<String>, String] policy_tags The policy tag list or
1165
+ # single policy tag for the field. Policy tag identifiers are of
1166
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
1167
+ # At most 1 policy tag is currently allowed.
1168
+ #
1169
+ # @example
1170
+ # require "google/cloud/bigquery"
1171
+ #
1172
+ # bigquery = Google::Cloud::Bigquery.new
1173
+ # dataset = bigquery.dataset "my_dataset"
1174
+ # job = dataset.load_job "my_table", "gs://abc/file" do |schema|
1175
+ # schema.record "cities_lived", mode: :repeated do |cities_lived|
1176
+ # cities_lived.geography "location", mode: :required
1177
+ # cities_lived.integer "number_of_years", mode: :required
1178
+ # end
1179
+ # end
1180
+ #
1181
+ def geography name, description: nil, mode: :nullable, policy_tags: nil
1182
+ schema.geography name, description: description, mode: mode, policy_tags: policy_tags
1183
+ end
1184
+
1149
1185
  ##
1150
1186
  # Adds a record field to the schema. A block must be passed describing
1151
1187
  # the nested fields of the record. For more information about nested
@@ -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`
@@ -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`
@@ -891,7 +891,7 @@ module Google
891
891
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql`
892
892
  # to true.
893
893
  #
894
- # Ruby types are mapped to BigQuery types as follows:
894
+ # BigQuery types are converted from Ruby types as follows:
895
895
  #
896
896
  # | BigQuery | Ruby | Notes |
897
897
  # |--------------|--------------------------------------|--------------------------------------------------|
@@ -899,10 +899,11 @@ module Google
899
899
  # | `INT64` | `Integer` | |
900
900
  # | `FLOAT64` | `Float` | |
901
901
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
902
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
902
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`. |
903
903
  # | `STRING` | `String` | |
904
904
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
905
905
  # | `DATE` | `Date` | |
906
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`. |
906
907
  # | `TIMESTAMP` | `Time` | |
907
908
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
908
909
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -910,7 +911,8 @@ module Google
910
911
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
911
912
  #
912
913
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
913
- # 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).
914
916
  #
915
917
  # @!group Attributes
916
918
  def params= params
@@ -926,7 +928,7 @@ module Google
926
928
  # use named query parameters. When set, `legacy_sql` will automatically be set to false and `standard_sql`
927
929
  # to true.
928
930
  #
929
- # Ruby types are mapped to BigQuery types as follows:
931
+ # BigQuery types are converted from Ruby types as follows:
930
932
  #
931
933
  # | BigQuery | Ruby | Notes |
932
934
  # |--------------|--------------------------------------|--------------------------------------------------|
@@ -934,10 +936,11 @@ module Google
934
936
  # | `INT64` | `Integer` | |
935
937
  # | `FLOAT64` | `Float` | |
936
938
  # | `NUMERIC` | `BigDecimal` | `BigDecimal` values will be rounded to scale 9. |
937
- # | `BIGNUMERIC` | | Query param values must be mapped in `types`. |
939
+ # | `BIGNUMERIC` | `BigDecimal` | NOT AUTOMATIC: Must be mapped using `types`. |
938
940
  # | `STRING` | `String` | |
939
941
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
940
942
  # | `DATE` | `Date` | |
943
+ # | `GEOGRAPHY` | `String` (WKT or GeoJSON) | NOT AUTOMATIC: Must be mapped using `types`. |
941
944
  # | `TIMESTAMP` | `Time` | |
942
945
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
943
946
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -945,7 +948,8 @@ module Google
945
948
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
946
949
  #
947
950
  # See [Data Types](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types) for an overview
948
- # 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).
949
953
  # @param [Array, Hash] types Standard SQL only. Types of the SQL parameters in `params`. It is not always
950
954
  # possible to infer the right SQL type from a value in `params`. In these cases, `types` must be used to
951
955
  # specify the SQL type for these values.
@@ -962,6 +966,7 @@ module Google
962
966
  # * `:STRING`
963
967
  # * `:DATETIME`
964
968
  # * `:DATE`
969
+ # * `:GEOGRAPHY`
965
970
  # * `:TIMESTAMP`
966
971
  # * `:TIME`
967
972
  # * `:BYTES`
@@ -566,6 +566,28 @@ module Google
566
566
  add_field name, :date, description: description, mode: mode, policy_tags: policy_tags
567
567
  end
568
568
 
569
+ ##
570
+ # Adds a geography field to the schema.
571
+ #
572
+ # @see https://cloud.google.com/bigquery/docs/gis-data Working with BigQuery GIS data
573
+ #
574
+ # @param [String] name The field name. The name must contain only
575
+ # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
576
+ # start with a letter or underscore. The maximum length is 128
577
+ # characters.
578
+ # @param [String] description A description of the field.
579
+ # @param [Symbol] mode The field's mode. The possible values are
580
+ # `:nullable`, `:required`, and `:repeated`. The default value is
581
+ # `:nullable`.
582
+ # @param [Array<String>, String] policy_tags The policy tag list or
583
+ # single policy tag for the field. Policy tag identifiers are of
584
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
585
+ # At most 1 policy tag is currently allowed.
586
+ #
587
+ def geography name, description: nil, mode: :nullable, policy_tags: nil
588
+ add_field name, :geography, description: description, mode: mode, policy_tags: policy_tags
589
+ end
590
+
569
591
  ##
570
592
  # Adds a record field to the schema. A block must be passed describing
571
593
  # the nested fields of the record. For more information about nested
@@ -40,8 +40,25 @@ 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.
@@ -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)
@@ -357,6 +400,15 @@ module Google
357
400
  type == "DATE"
358
401
  end
359
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
+
360
412
  ##
361
413
  # Checks if the type of the field is `RECORD`.
362
414
  #
@@ -770,6 +822,30 @@ module Google
770
822
  add_field name, :date, description: description, mode: mode, policy_tags: policy_tags
771
823
  end
772
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-z, A-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
847
+ end
848
+
773
849
  ##
774
850
  # Adds a record field to the nested schema of a record field. A block
775
851
  # must be passed describing the nested fields of the record. For more
@@ -601,7 +601,7 @@ module Google
601
601
 
602
602
  protected
603
603
 
604
- def retry? result, current_retries #:nodoc:
604
+ def retry? result, current_retries
605
605
  if current_retries < @retries && retry_error_reason?(result)
606
606
  return true
607
607
  end
@@ -2369,12 +2369,15 @@ module Google
2369
2369
  # | `BIGNUMERIC` | `String` | Pass as `String` to avoid rounding to scale 9. |
2370
2370
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
2371
2371
  # | `DATE` | `Date` | |
2372
+ # | `GEOGRAPHY` | `String` | Well-known text (WKT) or GeoJSON. |
2372
2373
  # | `TIMESTAMP` | `Time` | |
2373
2374
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
2374
2375
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
2375
2376
  # | `ARRAY` | `Array` | Nested arrays, `nil` values are not supported. |
2376
2377
  # | `STRUCT` | `Hash` | Hash keys may be strings or symbols. |
2377
2378
  #
2379
+ # For `GEOGRAPHY` data, see [Working with BigQuery GIS data](https://cloud.google.com/bigquery/docs/gis-data).
2380
+ #
2378
2381
  # Because BigQuery's streaming API is designed for high insertion rates,
2379
2382
  # modifications to the underlying table metadata are eventually
2380
2383
  # consistent when interacting with the streaming system. In most cases
@@ -3633,6 +3636,37 @@ module Google
3633
3636
  schema.date name, description: description, mode: mode, policy_tags: policy_tags
3634
3637
  end
3635
3638
 
3639
+ ##
3640
+ # Adds a geography field to the schema.
3641
+ #
3642
+ # @see https://cloud.google.com/bigquery/docs/gis-data Working with BigQuery GIS data
3643
+ #
3644
+ # @param [String] name The field name. The name must contain only
3645
+ # letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
3646
+ # start with a letter or underscore. The maximum length is 128
3647
+ # characters.
3648
+ # @param [String] description A description of the field.
3649
+ # @param [Symbol] mode The field's mode. The possible values are
3650
+ # `:nullable`, `:required`, and `:repeated`. The default value is
3651
+ # `:nullable`.
3652
+ # @param [Array<String>, String] policy_tags The policy tag list or
3653
+ # single policy tag for the field. Policy tag identifiers are of
3654
+ # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3655
+ # At most 1 policy tag is currently allowed.
3656
+ #
3657
+ # @example
3658
+ # require "google/cloud/bigquery"
3659
+ #
3660
+ # bigquery = Google::Cloud::Bigquery.new
3661
+ # dataset = bigquery.dataset "my_dataset"
3662
+ # table = dataset.create_table "my_table" do |schema|
3663
+ # schema.geography "home", mode: :required
3664
+ # end
3665
+ #
3666
+ def geography name, description: nil, mode: :nullable, policy_tags: nil
3667
+ schema.geography name, description: description, mode: mode, policy_tags: policy_tags
3668
+ end
3669
+
3636
3670
  ##
3637
3671
  # Adds a record field to the schema. A block must be passed describing
3638
3672
  # the nested fields of the record. For more information about nested
@@ -110,6 +110,7 @@ module Google
110
110
  # | `BIGNUMERIC` | `String` | Pass as `String` to avoid rounding to scale 9. |
111
111
  # | `DATETIME` | `DateTime` | `DATETIME` does not support time zone. |
112
112
  # | `DATE` | `Date` | |
113
+ # | `GEOGRAPHY` | `String` | |
113
114
  # | `TIMESTAMP` | `Time` | |
114
115
  # | `TIME` | `Google::Cloud::BigQuery::Time` | |
115
116
  # | `BYTES` | `File`, `IO`, `StringIO`, or similar | |
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.34.0".freeze
19
+ VERSION = "1.35.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.34.0
4
+ version: 1.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-07-20 00:00:00.000000000 Z
12
+ date: 2021-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby