google-cloud-bigquery 1.52.1 → 1.61.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.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +12 -1
- data/CHANGELOG.md +69 -0
- data/OVERVIEW.md +4 -4
- data/lib/google/cloud/bigquery/condition.rb +218 -0
- data/lib/google/cloud/bigquery/convert.rb +10 -1
- data/lib/google/cloud/bigquery/copy_job.rb +14 -1
- data/lib/google/cloud/bigquery/data.rb +9 -3
- data/lib/google/cloud/bigquery/dataset/access.rb +281 -28
- data/lib/google/cloud/bigquery/dataset.rb +282 -19
- data/lib/google/cloud/bigquery/external/csv_source.rb +218 -0
- data/lib/google/cloud/bigquery/external/data_source.rb +264 -0
- data/lib/google/cloud/bigquery/extract_job.rb +14 -1
- data/lib/google/cloud/bigquery/job.rb +6 -4
- data/lib/google/cloud/bigquery/load_job.rb +227 -0
- data/lib/google/cloud/bigquery/model.rb +15 -4
- data/lib/google/cloud/bigquery/project.rb +226 -23
- data/lib/google/cloud/bigquery/query_job.rb +22 -6
- data/lib/google/cloud/bigquery/remote_function_options.rb +156 -0
- data/lib/google/cloud/bigquery/routine.rb +153 -0
- data/lib/google/cloud/bigquery/schema/field.rb +31 -3
- data/lib/google/cloud/bigquery/schema.rb +6 -3
- data/lib/google/cloud/bigquery/service.rb +19 -12
- data/lib/google/cloud/bigquery/table.rb +326 -29
- data/lib/google/cloud/bigquery/version.rb +1 -1
- data/lib/google/cloud/bigquery.rb +25 -9
- data/lib/google-cloud-bigquery.rb +19 -3
- metadata +15 -7
|
@@ -752,6 +752,37 @@ module Google
|
|
|
752
752
|
patch_gapi! :description
|
|
753
753
|
end
|
|
754
754
|
|
|
755
|
+
##
|
|
756
|
+
# The default collation of the table.
|
|
757
|
+
#
|
|
758
|
+
# @return [String, nil] The default collation, or `nil` if not present or the object is a
|
|
759
|
+
# reference (see {#reference?}).
|
|
760
|
+
#
|
|
761
|
+
# @!group Attributes
|
|
762
|
+
#
|
|
763
|
+
def default_collation
|
|
764
|
+
return nil if reference?
|
|
765
|
+
ensure_full_data!
|
|
766
|
+
@gapi.default_collation
|
|
767
|
+
end
|
|
768
|
+
|
|
769
|
+
##
|
|
770
|
+
# Updates the default collation of the table.
|
|
771
|
+
#
|
|
772
|
+
# If the table is not a full resource representation (see
|
|
773
|
+
# {#resource_full?}), the full representation will be retrieved before
|
|
774
|
+
# the update to comply with ETag-based optimistic concurrency control.
|
|
775
|
+
#
|
|
776
|
+
# @param [String] new_default_collation The new default collation for the table.
|
|
777
|
+
#
|
|
778
|
+
# @!group Attributes
|
|
779
|
+
#
|
|
780
|
+
def default_collation= new_default_collation
|
|
781
|
+
reload! unless resource_full?
|
|
782
|
+
@gapi.update! default_collation: new_default_collation
|
|
783
|
+
patch_gapi! :default_collation
|
|
784
|
+
end
|
|
785
|
+
|
|
755
786
|
##
|
|
756
787
|
# The number of bytes in the table.
|
|
757
788
|
#
|
|
@@ -1017,6 +1048,77 @@ module Google
|
|
|
1017
1048
|
patch_gapi! :labels
|
|
1018
1049
|
end
|
|
1019
1050
|
|
|
1051
|
+
##
|
|
1052
|
+
# The resource tags associated with this table. Tag keys are globally unique.
|
|
1053
|
+
#
|
|
1054
|
+
# @see https://cloud.google.com/iam/docs/tags-access-control#definitions
|
|
1055
|
+
# For additional information on tags.
|
|
1056
|
+
#
|
|
1057
|
+
# The returned hash is frozen and changes are not allowed. Use
|
|
1058
|
+
# {#resource_tags=} to replace the entire hash.
|
|
1059
|
+
#
|
|
1060
|
+
# @return [Hash<String, String>, nil] A hash containing key/value pairs.
|
|
1061
|
+
#
|
|
1062
|
+
# * The key is the namespaced friendly name of the tag key, e.g.
|
|
1063
|
+
# "12345/environment" where 12345 is the ID of the parent organization
|
|
1064
|
+
# or project resource for this tag key.
|
|
1065
|
+
# * The value is the friendly short name of the tag value, e.g. "production".
|
|
1066
|
+
#
|
|
1067
|
+
# @example
|
|
1068
|
+
# require "google/cloud/bigquery"
|
|
1069
|
+
#
|
|
1070
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
1071
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
1072
|
+
# table = dataset.table "my_table"
|
|
1073
|
+
#
|
|
1074
|
+
# resource_tags = table.resource_tags
|
|
1075
|
+
# resource_tags["12345/environment"] #=> "production"
|
|
1076
|
+
#
|
|
1077
|
+
# @!group Attributes
|
|
1078
|
+
#
|
|
1079
|
+
def resource_tags
|
|
1080
|
+
return nil if reference?
|
|
1081
|
+
m = @gapi.resource_tags
|
|
1082
|
+
m = m.to_h if m.respond_to? :to_h
|
|
1083
|
+
m.dup.freeze
|
|
1084
|
+
end
|
|
1085
|
+
|
|
1086
|
+
##
|
|
1087
|
+
# Updates the resource tags associated with this table. Tag keys are globally
|
|
1088
|
+
# unique.
|
|
1089
|
+
#
|
|
1090
|
+
# @see https://cloud.google.com/iam/docs/tags-access-control#definitions
|
|
1091
|
+
# For additional information on tags.
|
|
1092
|
+
#
|
|
1093
|
+
# If the table is not a full resource representation (see
|
|
1094
|
+
# {#resource_full?}), the full representation will be retrieved before
|
|
1095
|
+
# the update to comply with ETag-based optimistic concurrency control.
|
|
1096
|
+
#
|
|
1097
|
+
# @param [Hash<String, String>] resource_tags A hash containing key/value
|
|
1098
|
+
# pairs.
|
|
1099
|
+
#
|
|
1100
|
+
# * The key is the namespaced friendly name of the tag key, e.g.
|
|
1101
|
+
# "12345/environment" where 12345 is the ID of the parent organization
|
|
1102
|
+
# or project resource for this tag key.
|
|
1103
|
+
# * The value is the friendly short name of the tag value, e.g. "production".
|
|
1104
|
+
#
|
|
1105
|
+
# @example
|
|
1106
|
+
# require "google/cloud/bigquery"
|
|
1107
|
+
#
|
|
1108
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
1109
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
1110
|
+
# table = dataset.table "my_table"
|
|
1111
|
+
#
|
|
1112
|
+
# table.resource_tags = { "12345/environment" => "production" }
|
|
1113
|
+
#
|
|
1114
|
+
# @!group Attributes
|
|
1115
|
+
#
|
|
1116
|
+
def resource_tags= resource_tags
|
|
1117
|
+
reload! unless resource_full?
|
|
1118
|
+
@gapi.resource_tags = resource_tags
|
|
1119
|
+
patch_gapi! :resource_tags
|
|
1120
|
+
end
|
|
1121
|
+
|
|
1020
1122
|
##
|
|
1021
1123
|
# Returns the table's schema. If the table is not a view (See {#view?}),
|
|
1022
1124
|
# this method can also be used to set, replace, or add to the schema by
|
|
@@ -1630,6 +1732,8 @@ module Google
|
|
|
1630
1732
|
#
|
|
1631
1733
|
# @param [Integer] max Maximum number of results to return.
|
|
1632
1734
|
# @param [Integer] start Zero-based index of the starting row to read.
|
|
1735
|
+
# @param [Boolean] format_options_use_int64_timestamp Output timestamp
|
|
1736
|
+
# as usec int64. Default is true.
|
|
1633
1737
|
#
|
|
1634
1738
|
# @return [Google::Cloud::Bigquery::Data]
|
|
1635
1739
|
#
|
|
@@ -1664,11 +1768,12 @@ module Google
|
|
|
1664
1768
|
#
|
|
1665
1769
|
# @!group Data
|
|
1666
1770
|
#
|
|
1667
|
-
def data token: nil, max: nil, start: nil
|
|
1771
|
+
def data token: nil, max: nil, start: nil, format_options_use_int64_timestamp: true
|
|
1668
1772
|
ensure_service!
|
|
1669
1773
|
reload! unless resource_full?
|
|
1670
|
-
data_json = service.list_tabledata dataset_id, table_id, token: token, max: max, start: start
|
|
1671
|
-
|
|
1774
|
+
data_json = service.list_tabledata dataset_id, table_id, token: token, max: max, start: start,
|
|
1775
|
+
format_options_use_int64_timestamp: format_options_use_int64_timestamp
|
|
1776
|
+
Data.from_gapi_json data_json, gapi, nil, service, format_options_use_int64_timestamp
|
|
1672
1777
|
end
|
|
1673
1778
|
|
|
1674
1779
|
##
|
|
@@ -1743,6 +1848,12 @@ module Google
|
|
|
1743
1848
|
# @param [Boolean] dryrun If set, don't actually run this job. Behavior
|
|
1744
1849
|
# is undefined however for non-query jobs and may result in an error.
|
|
1745
1850
|
# Deprecated.
|
|
1851
|
+
# @param [String] operation_type The type of operation for this job.
|
|
1852
|
+
# @param [String] reservation The reservation that job would use. User
|
|
1853
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
1854
|
+
# set, reservation is determined based on the rules defined by the
|
|
1855
|
+
# reservation assignments. The expected format is
|
|
1856
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
1746
1857
|
#
|
|
1747
1858
|
# @yield [job] a job configuration object
|
|
1748
1859
|
# @yieldparam [Google::Cloud::Bigquery::CopyJob::Updater] job a job
|
|
@@ -1775,7 +1886,7 @@ module Google
|
|
|
1775
1886
|
# @!group Data
|
|
1776
1887
|
#
|
|
1777
1888
|
def copy_job destination_table, create: nil, write: nil, job_id: nil, prefix: nil, labels: nil, dryrun: nil,
|
|
1778
|
-
operation_type: nil
|
|
1889
|
+
operation_type: nil, reservation: nil
|
|
1779
1890
|
ensure_service!
|
|
1780
1891
|
options = { create: create,
|
|
1781
1892
|
write: write,
|
|
@@ -1783,7 +1894,8 @@ module Google
|
|
|
1783
1894
|
labels: labels,
|
|
1784
1895
|
job_id: job_id,
|
|
1785
1896
|
prefix: prefix,
|
|
1786
|
-
operation_type: operation_type
|
|
1897
|
+
operation_type: operation_type,
|
|
1898
|
+
reservation: reservation }
|
|
1787
1899
|
updater = CopyJob::Updater.from_options(
|
|
1788
1900
|
service,
|
|
1789
1901
|
table_ref,
|
|
@@ -1836,6 +1948,12 @@ module Google
|
|
|
1836
1948
|
# * `append` - BigQuery appends the data to the table.
|
|
1837
1949
|
# * `empty` - An error will be returned if the destination table
|
|
1838
1950
|
# already contains data.
|
|
1951
|
+
# @param [String] reservation The reservation that job would use. User
|
|
1952
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
1953
|
+
# set, reservation is determined based on the rules defined by the
|
|
1954
|
+
# reservation assignments. The expected format is
|
|
1955
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
1956
|
+
#
|
|
1839
1957
|
# @yield [job] a job configuration object
|
|
1840
1958
|
# @yieldparam [Google::Cloud::Bigquery::CopyJob::Updater] job a job
|
|
1841
1959
|
# configuration object for setting additional options.
|
|
@@ -1863,11 +1981,12 @@ module Google
|
|
|
1863
1981
|
#
|
|
1864
1982
|
# @!group Data
|
|
1865
1983
|
#
|
|
1866
|
-
def copy destination_table, create: nil, write: nil, &block
|
|
1984
|
+
def copy destination_table, create: nil, write: nil, reservation: nil, &block
|
|
1867
1985
|
copy_job_with_operation_type destination_table,
|
|
1868
1986
|
create: create,
|
|
1869
1987
|
write: write,
|
|
1870
1988
|
operation_type: OperationType::COPY,
|
|
1989
|
+
reservation: reservation,
|
|
1871
1990
|
&block
|
|
1872
1991
|
end
|
|
1873
1992
|
|
|
@@ -1893,6 +2012,11 @@ module Google
|
|
|
1893
2012
|
# Reference](https://cloud.google.com/bigquery/query-reference#from)
|
|
1894
2013
|
# (`project-name:dataset_id.table_id`). This is useful for referencing
|
|
1895
2014
|
# tables in other projects and datasets.
|
|
2015
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2016
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2017
|
+
# set, reservation is determined based on the rules defined by the
|
|
2018
|
+
# reservation assignments. The expected format is
|
|
2019
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
1896
2020
|
#
|
|
1897
2021
|
# @yield [job] a job configuration object
|
|
1898
2022
|
# @yieldparam [Google::Cloud::Bigquery::CopyJob::Updater] job a job
|
|
@@ -1921,9 +2045,10 @@ module Google
|
|
|
1921
2045
|
#
|
|
1922
2046
|
# @!group Data
|
|
1923
2047
|
#
|
|
1924
|
-
def clone destination_table, &block
|
|
2048
|
+
def clone destination_table, reservation: nil, &block
|
|
1925
2049
|
copy_job_with_operation_type destination_table,
|
|
1926
2050
|
operation_type: OperationType::CLONE,
|
|
2051
|
+
reservation: reservation,
|
|
1927
2052
|
&block
|
|
1928
2053
|
end
|
|
1929
2054
|
|
|
@@ -1948,6 +2073,11 @@ module Google
|
|
|
1948
2073
|
# Reference](https://cloud.google.com/bigquery/query-reference#from)
|
|
1949
2074
|
# (`project-name:dataset_id.table_id`). This is useful for referencing
|
|
1950
2075
|
# tables in other projects and datasets.
|
|
2076
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2077
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2078
|
+
# set, reservation is determined based on the rules defined by the
|
|
2079
|
+
# reservation assignments. The expected format is
|
|
2080
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
1951
2081
|
#
|
|
1952
2082
|
# @yield [job] a job configuration object
|
|
1953
2083
|
# @yieldparam [Google::Cloud::Bigquery::CopyJob::Updater] job a job
|
|
@@ -1976,9 +2106,10 @@ module Google
|
|
|
1976
2106
|
#
|
|
1977
2107
|
# @!group Data
|
|
1978
2108
|
#
|
|
1979
|
-
def snapshot destination_table, &block
|
|
2109
|
+
def snapshot destination_table, reservation: nil, &block
|
|
1980
2110
|
copy_job_with_operation_type destination_table,
|
|
1981
2111
|
operation_type: OperationType::SNAPSHOT,
|
|
2112
|
+
reservation: reservation,
|
|
1982
2113
|
&block
|
|
1983
2114
|
end
|
|
1984
2115
|
|
|
@@ -2020,6 +2151,12 @@ module Google
|
|
|
2020
2151
|
# * `append` - BigQuery appends the data to the table.
|
|
2021
2152
|
# * `empty` - An error will be returned if the destination table
|
|
2022
2153
|
# already contains data.
|
|
2154
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2155
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2156
|
+
# set, reservation is determined based on the rules defined by the
|
|
2157
|
+
# reservation assignments. The expected format is
|
|
2158
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2159
|
+
#
|
|
2023
2160
|
# @yield [job] a job configuration object
|
|
2024
2161
|
# @yieldparam [Google::Cloud::Bigquery::CopyJob::Updater] job a job
|
|
2025
2162
|
# configuration object for setting additional options.
|
|
@@ -2047,11 +2184,12 @@ module Google
|
|
|
2047
2184
|
#
|
|
2048
2185
|
# @!group Data
|
|
2049
2186
|
#
|
|
2050
|
-
def restore destination_table, create: nil, write: nil, &block
|
|
2187
|
+
def restore destination_table, create: nil, write: nil, reservation: nil, &block
|
|
2051
2188
|
copy_job_with_operation_type destination_table,
|
|
2052
2189
|
create: create,
|
|
2053
2190
|
write: write,
|
|
2054
2191
|
operation_type: OperationType::RESTORE,
|
|
2192
|
+
reservation: reservation,
|
|
2055
2193
|
&block
|
|
2056
2194
|
end
|
|
2057
2195
|
|
|
@@ -2124,6 +2262,11 @@ module Google
|
|
|
2124
2262
|
# @param [Boolean] dryrun If set, don't actually run this job. Behavior
|
|
2125
2263
|
# is undefined however for non-query jobs and may result in an error.
|
|
2126
2264
|
# Deprecated.
|
|
2265
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2266
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2267
|
+
# set, reservation is determined based on the rules defined by the
|
|
2268
|
+
# reservation assignments. The expected format is
|
|
2269
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2127
2270
|
#
|
|
2128
2271
|
# @yield [job] a job configuration object
|
|
2129
2272
|
# @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
|
|
@@ -2146,10 +2289,10 @@ module Google
|
|
|
2146
2289
|
# @!group Data
|
|
2147
2290
|
#
|
|
2148
2291
|
def extract_job extract_url, format: nil, compression: nil, delimiter: nil, header: nil, job_id: nil,
|
|
2149
|
-
prefix: nil, labels: nil, dryrun: nil
|
|
2292
|
+
prefix: nil, labels: nil, dryrun: nil, reservation: nil
|
|
2150
2293
|
ensure_service!
|
|
2151
2294
|
options = { format: format, compression: compression, delimiter: delimiter, header: header, dryrun: dryrun,
|
|
2152
|
-
job_id: job_id, prefix: prefix, labels: labels }
|
|
2295
|
+
job_id: job_id, prefix: prefix, labels: labels, reservation: reservation }
|
|
2153
2296
|
updater = ExtractJob::Updater.from_options service, table_ref, extract_url, options
|
|
2154
2297
|
updater.location = location if location # may be table reference
|
|
2155
2298
|
|
|
@@ -2193,6 +2336,12 @@ module Google
|
|
|
2193
2336
|
# exported data. Default is <code>,</code>.
|
|
2194
2337
|
# @param [Boolean] header Whether to print out a header row in the
|
|
2195
2338
|
# results. Default is `true`.
|
|
2339
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2340
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2341
|
+
# set, reservation is determined based on the rules defined by the
|
|
2342
|
+
# reservation assignments. The expected format is
|
|
2343
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2344
|
+
#
|
|
2196
2345
|
# @yield [job] a job configuration object
|
|
2197
2346
|
# @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
|
|
2198
2347
|
# configuration object for setting additional options.
|
|
@@ -2221,12 +2370,13 @@ module Google
|
|
|
2221
2370
|
#
|
|
2222
2371
|
# @!group Data
|
|
2223
2372
|
#
|
|
2224
|
-
def extract extract_url, format: nil, compression: nil, delimiter: nil, header: nil, &block
|
|
2373
|
+
def extract extract_url, format: nil, compression: nil, delimiter: nil, header: nil, reservation: nil, &block
|
|
2225
2374
|
job = extract_job extract_url,
|
|
2226
2375
|
format: format,
|
|
2227
2376
|
compression: compression,
|
|
2228
2377
|
delimiter: delimiter,
|
|
2229
2378
|
header: header,
|
|
2379
|
+
reservation: reservation,
|
|
2230
2380
|
&block
|
|
2231
2381
|
job.wait_until_done!
|
|
2232
2382
|
ensure_job_succeeded! job
|
|
@@ -2377,6 +2527,53 @@ module Google
|
|
|
2377
2527
|
# Note: This will work only for tables in _SESSION dataset
|
|
2378
2528
|
# else the property will be ignored by the backend.
|
|
2379
2529
|
# @param [string] session_id Session ID in which the load job must run.
|
|
2530
|
+
# @param [String] date_format Format used to parse DATE values.
|
|
2531
|
+
# Supports SQL-style format strings. See
|
|
2532
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2533
|
+
# @param [String] datetime_format Format used to parse DATETIME
|
|
2534
|
+
# values. Supports SQL-style format strings. See
|
|
2535
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2536
|
+
# @param [String] time_format Format used to parse TIME values.
|
|
2537
|
+
# Supports SQL-style format strings. See
|
|
2538
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2539
|
+
# @param [String] timestamp_format Format used to parse
|
|
2540
|
+
# TIMESTAMP values. Supports SQL-style format strings. See
|
|
2541
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2542
|
+
# @param [Array<String>] null_markers A list of strings represented as
|
|
2543
|
+
# SQL NULL value in a CSV file. null_marker and null_markers can't be
|
|
2544
|
+
# set at the same time. If null_marker is set, null_markers has to be
|
|
2545
|
+
# not set. If null_markers is set, null_marker has to be not set. If
|
|
2546
|
+
# both null_marker and null_markers are set at the same time, a user
|
|
2547
|
+
# error would be thrown. Any strings listed in null_markers, including
|
|
2548
|
+
# empty string would be interpreted as SQL NULL. This applies to all
|
|
2549
|
+
# column types.
|
|
2550
|
+
# @param [String] source_column_match Controls the strategy used to
|
|
2551
|
+
# match loaded columns to the schema. If not set, a sensible default is
|
|
2552
|
+
# chosen based on how the schema is provided. If autodetect is used,
|
|
2553
|
+
# then columns are matched by name. Otherwise, columns are matched by
|
|
2554
|
+
# position. This is done to keep the behavior backward-compatible.
|
|
2555
|
+
#
|
|
2556
|
+
# Acceptable values are:
|
|
2557
|
+
# * `POSITION` - matches by position. This assumes that the columns are
|
|
2558
|
+
# ordered the same way as the schema.
|
|
2559
|
+
# * `NAME` - matches by name. This reads the header row as column names
|
|
2560
|
+
# and reorders columns to match the field names in the schema.
|
|
2561
|
+
# @param [String] time_zone The time zone used when parsing timestamp
|
|
2562
|
+
# values.
|
|
2563
|
+
# @param [String] reference_file_schema_uri The URI of the reference
|
|
2564
|
+
# file with the reader schema. This file is only loaded if it is part
|
|
2565
|
+
# of source URIs, but is not loaded otherwise. It is enabled for the
|
|
2566
|
+
# following formats: `AVRO`, `PARQUET`, `ORC`.
|
|
2567
|
+
# @param [Boolean] preserve_ascii_control_characters When source_format
|
|
2568
|
+
# is set to `CSV`, indicates if the embedded ASCII control characters
|
|
2569
|
+
# (the first 32 characters in the ASCII-table, from `\x00` to `\x1F`)
|
|
2570
|
+
# are preserved. By default, ASCII control characters are not
|
|
2571
|
+
# preserved.
|
|
2572
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2573
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2574
|
+
# set, reservation is determined based on the rules defined by the
|
|
2575
|
+
# reservation assignments. The expected format is
|
|
2576
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2380
2577
|
#
|
|
2381
2578
|
# @yield [load_job] a block for setting the load job
|
|
2382
2579
|
# @yieldparam [LoadJob] load_job the load job object to be updated
|
|
@@ -2433,7 +2630,10 @@ module Google
|
|
|
2433
2630
|
def load_job files, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
|
2434
2631
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil,
|
|
2435
2632
|
quote: nil, skip_leading: nil, job_id: nil, prefix: nil, labels: nil, autodetect: nil,
|
|
2436
|
-
null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, schema: self.schema
|
|
2633
|
+
null_marker: nil, dryrun: nil, create_session: nil, session_id: nil, schema: self.schema,
|
|
2634
|
+
date_format: nil, datetime_format: nil, time_format: nil, timestamp_format: nil,
|
|
2635
|
+
null_markers: nil, source_column_match: nil, time_zone: nil, reference_file_schema_uri: nil,
|
|
2636
|
+
preserve_ascii_control_characters: nil, reservation: nil
|
|
2437
2637
|
ensure_service!
|
|
2438
2638
|
|
|
2439
2639
|
updater = load_job_updater format: format, create: create, write: write, projection_fields: projection_fields,
|
|
@@ -2442,8 +2642,13 @@ module Google
|
|
|
2442
2642
|
max_bad_records: max_bad_records, quote: quote, skip_leading: skip_leading,
|
|
2443
2643
|
dryrun: dryrun, job_id: job_id, prefix: prefix, schema: schema, labels: labels,
|
|
2444
2644
|
autodetect: autodetect, null_marker: null_marker, create_session: create_session,
|
|
2445
|
-
session_id: session_id
|
|
2446
|
-
|
|
2645
|
+
session_id: session_id, date_format: date_format,
|
|
2646
|
+
datetime_format: datetime_format, time_format: time_format,
|
|
2647
|
+
timestamp_format: timestamp_format, null_markers: null_markers,
|
|
2648
|
+
source_column_match: source_column_match, time_zone: time_zone,
|
|
2649
|
+
reference_file_schema_uri: reference_file_schema_uri,
|
|
2650
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters,
|
|
2651
|
+
reservation: reservation
|
|
2447
2652
|
|
|
2448
2653
|
yield updater if block_given?
|
|
2449
2654
|
|
|
@@ -2559,6 +2764,53 @@ module Google
|
|
|
2559
2764
|
# value is `0`. This property is useful if you have header rows in the
|
|
2560
2765
|
# file that should be skipped.
|
|
2561
2766
|
# @param [string] session_id Session ID in which the load job must run.
|
|
2767
|
+
# @param [String] date_format Format used to parse DATE values.
|
|
2768
|
+
# Supports SQL-style format strings. See
|
|
2769
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2770
|
+
# @param [String] datetime_format Format used to parse DATETIME
|
|
2771
|
+
# values. Supports SQL-style format strings. See
|
|
2772
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2773
|
+
# @param [String] time_format Format used to parse TIME values.
|
|
2774
|
+
# Supports SQL-style format strings. See
|
|
2775
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2776
|
+
# @param [String] timestamp_format Format used to parse
|
|
2777
|
+
# TIMESTAMP values. Supports SQL-style format strings. See
|
|
2778
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2779
|
+
# @param [Array<String>] null_markers A list of strings represented as
|
|
2780
|
+
# SQL NULL value in a CSV file. null_marker and null_markers can't be
|
|
2781
|
+
# set at the same time. If null_marker is set, null_markers has to be
|
|
2782
|
+
# not set. If null_markers is set, null_marker has to be not set. If
|
|
2783
|
+
# both null_marker and null_markers are set at the same time, a user
|
|
2784
|
+
# error would be thrown. Any strings listed in null_markers, including
|
|
2785
|
+
# empty string would be interpreted as SQL NULL. This applies to all
|
|
2786
|
+
# column types.
|
|
2787
|
+
# @param [String] source_column_match Controls the strategy used to
|
|
2788
|
+
# match loaded columns to the schema. If not set, a sensible default is
|
|
2789
|
+
# chosen based on how the schema is provided. If autodetect is used,
|
|
2790
|
+
# then columns are matched by name. Otherwise, columns are matched by
|
|
2791
|
+
# position. This is done to keep the behavior backward-compatible.
|
|
2792
|
+
#
|
|
2793
|
+
# Acceptable values are:
|
|
2794
|
+
# * `POSITION` - matches by position. This assumes that the columns are
|
|
2795
|
+
# ordered the same way as the schema.
|
|
2796
|
+
# * `NAME` - matches by name. This reads the header row as column names
|
|
2797
|
+
# and reorders columns to match the field names in the schema.
|
|
2798
|
+
# @param [String] time_zone The time zone used when parsing timestamp
|
|
2799
|
+
# values.
|
|
2800
|
+
# @param [String] reference_file_schema_uri The URI of the reference
|
|
2801
|
+
# file with the reader schema. This file is only loaded if it is part
|
|
2802
|
+
# of source URIs, but is not loaded otherwise. It is enabled for the
|
|
2803
|
+
# following formats: `AVRO`, `PARQUET`, `ORC`.
|
|
2804
|
+
# @param [Boolean] preserve_ascii_control_characters When source_format
|
|
2805
|
+
# is set to `CSV`, indicates if the embedded ASCII control characters
|
|
2806
|
+
# (the first 32 characters in the ASCII-table, from `\x00` to `\x1F`)
|
|
2807
|
+
# are preserved. By default, ASCII control characters are not
|
|
2808
|
+
# preserved.
|
|
2809
|
+
# @param [String] reservation The reservation that job would use. User
|
|
2810
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
2811
|
+
# set, reservation is determined based on the rules defined by the
|
|
2812
|
+
# reservation assignments. The expected format is
|
|
2813
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2562
2814
|
#
|
|
2563
2815
|
# @yield [updater] A block for setting the schema of the destination
|
|
2564
2816
|
# table and other options for the load job. The schema can be omitted
|
|
@@ -2621,12 +2873,20 @@ module Google
|
|
|
2621
2873
|
def load files, format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
|
2622
2874
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil,
|
|
2623
2875
|
quote: nil, skip_leading: nil, autodetect: nil, null_marker: nil, session_id: nil,
|
|
2624
|
-
schema: self.schema,
|
|
2876
|
+
schema: self.schema, date_format: nil, datetime_format: nil, time_format: nil, timestamp_format: nil,
|
|
2877
|
+
null_markers: nil, source_column_match: nil, time_zone: nil, reference_file_schema_uri: nil,
|
|
2878
|
+
preserve_ascii_control_characters: nil, reservation: nil, &block
|
|
2625
2879
|
job = load_job files, format: format, create: create, write: write, projection_fields: projection_fields,
|
|
2626
2880
|
jagged_rows: jagged_rows, quoted_newlines: quoted_newlines, encoding: encoding,
|
|
2627
2881
|
delimiter: delimiter, ignore_unknown: ignore_unknown, max_bad_records: max_bad_records,
|
|
2628
2882
|
quote: quote, skip_leading: skip_leading, autodetect: autodetect,
|
|
2629
|
-
null_marker: null_marker, session_id: session_id, schema: schema,
|
|
2883
|
+
null_marker: null_marker, session_id: session_id, schema: schema,
|
|
2884
|
+
date_format: date_format, datetime_format: datetime_format, time_format: time_format,
|
|
2885
|
+
timestamp_format: timestamp_format, null_markers: null_markers,
|
|
2886
|
+
source_column_match: source_column_match, time_zone: time_zone,
|
|
2887
|
+
reference_file_schema_uri: reference_file_schema_uri,
|
|
2888
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters,
|
|
2889
|
+
reservation: reservation, &block
|
|
2630
2890
|
|
|
2631
2891
|
job.wait_until_done!
|
|
2632
2892
|
ensure_job_succeeded! job
|
|
@@ -3020,11 +3280,13 @@ module Google
|
|
|
3020
3280
|
|
|
3021
3281
|
protected
|
|
3022
3282
|
|
|
3023
|
-
def copy_job_with_operation_type destination_table, create: nil, write: nil, operation_type: nil,
|
|
3283
|
+
def copy_job_with_operation_type destination_table, create: nil, write: nil, operation_type: nil,
|
|
3284
|
+
reservation: nil, &block
|
|
3024
3285
|
job = copy_job destination_table,
|
|
3025
3286
|
create: create,
|
|
3026
3287
|
write: write,
|
|
3027
3288
|
operation_type: operation_type,
|
|
3289
|
+
reservation: reservation,
|
|
3028
3290
|
&block
|
|
3029
3291
|
job.wait_until_done!
|
|
3030
3292
|
ensure_job_succeeded! job
|
|
@@ -3075,7 +3337,7 @@ module Google
|
|
|
3075
3337
|
end
|
|
3076
3338
|
end
|
|
3077
3339
|
|
|
3078
|
-
def load_job_gapi table_id, dryrun, job_id: nil, prefix: nil
|
|
3340
|
+
def load_job_gapi table_id, dryrun, job_id: nil, prefix: nil, reservation: nil
|
|
3079
3341
|
job_ref = service.job_ref_from job_id, prefix
|
|
3080
3342
|
Google::Apis::BigqueryV2::Job.new(
|
|
3081
3343
|
job_reference: job_ref,
|
|
@@ -3087,43 +3349,64 @@ module Google
|
|
|
3087
3349
|
table_id: table_id
|
|
3088
3350
|
)
|
|
3089
3351
|
),
|
|
3090
|
-
dry_run: dryrun
|
|
3352
|
+
dry_run: dryrun,
|
|
3353
|
+
reservation: reservation
|
|
3091
3354
|
)
|
|
3092
3355
|
)
|
|
3093
3356
|
end
|
|
3094
3357
|
|
|
3095
3358
|
def load_job_csv_options! job, jagged_rows: nil, quoted_newlines: nil, delimiter: nil, quote: nil,
|
|
3096
|
-
skip_leading: nil, null_marker: nil
|
|
3359
|
+
skip_leading: nil, null_marker: nil, null_markers: nil, source_column_match: nil,
|
|
3360
|
+
preserve_ascii_control_characters: nil
|
|
3097
3361
|
job.jagged_rows = jagged_rows unless jagged_rows.nil?
|
|
3098
3362
|
job.quoted_newlines = quoted_newlines unless quoted_newlines.nil?
|
|
3099
3363
|
job.delimiter = delimiter unless delimiter.nil?
|
|
3100
3364
|
job.null_marker = null_marker unless null_marker.nil?
|
|
3101
3365
|
job.quote = quote unless quote.nil?
|
|
3102
3366
|
job.skip_leading = skip_leading unless skip_leading.nil?
|
|
3367
|
+
job.null_markers = null_markers unless null_markers.nil?
|
|
3368
|
+
job.source_column_match = source_column_match unless source_column_match.nil?
|
|
3369
|
+
job.preserve_ascii_control_characters = preserve_ascii_control_characters unless
|
|
3370
|
+
preserve_ascii_control_characters.nil?
|
|
3103
3371
|
end
|
|
3104
3372
|
|
|
3105
3373
|
def load_job_file_options! job, format: nil, projection_fields: nil, jagged_rows: nil, quoted_newlines: nil,
|
|
3106
3374
|
encoding: nil, delimiter: nil, ignore_unknown: nil, max_bad_records: nil, quote: nil,
|
|
3107
|
-
skip_leading: nil, null_marker: nil
|
|
3375
|
+
skip_leading: nil, null_marker: nil, date_format: nil, datetime_format: nil,
|
|
3376
|
+
time_format: nil, timestamp_format: nil, null_markers: nil, source_column_match: nil,
|
|
3377
|
+
time_zone: nil, reference_file_schema_uri: nil,
|
|
3378
|
+
preserve_ascii_control_characters: nil
|
|
3108
3379
|
job.format = format unless format.nil?
|
|
3109
3380
|
job.projection_fields = projection_fields unless projection_fields.nil?
|
|
3110
3381
|
job.encoding = encoding unless encoding.nil?
|
|
3111
3382
|
job.ignore_unknown = ignore_unknown unless ignore_unknown.nil?
|
|
3112
3383
|
job.max_bad_records = max_bad_records unless max_bad_records.nil?
|
|
3384
|
+
job.date_format = date_format unless date_format.nil?
|
|
3385
|
+
job.datetime_format = datetime_format unless datetime_format.nil?
|
|
3386
|
+
job.time_format = time_format unless time_format.nil?
|
|
3387
|
+
job.timestamp_format = timestamp_format unless timestamp_format.nil?
|
|
3388
|
+
job.time_zone = time_zone unless time_zone.nil?
|
|
3389
|
+
job.reference_file_schema_uri = reference_file_schema_uri unless reference_file_schema_uri.nil?
|
|
3113
3390
|
load_job_csv_options! job, jagged_rows: jagged_rows,
|
|
3114
3391
|
quoted_newlines: quoted_newlines,
|
|
3115
3392
|
delimiter: delimiter,
|
|
3116
3393
|
quote: quote,
|
|
3117
3394
|
skip_leading: skip_leading,
|
|
3118
|
-
null_marker: null_marker
|
|
3395
|
+
null_marker: null_marker,
|
|
3396
|
+
null_markers: null_markers,
|
|
3397
|
+
source_column_match: source_column_match,
|
|
3398
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters
|
|
3119
3399
|
end
|
|
3120
3400
|
|
|
3121
3401
|
def load_job_updater format: nil, create: nil, write: nil, projection_fields: nil, jagged_rows: nil,
|
|
3122
3402
|
quoted_newlines: nil, encoding: nil, delimiter: nil, ignore_unknown: nil,
|
|
3123
3403
|
max_bad_records: nil, quote: nil, skip_leading: nil, dryrun: nil, schema: nil, job_id: nil,
|
|
3124
3404
|
prefix: nil, labels: nil, autodetect: nil, null_marker: nil,
|
|
3125
|
-
create_session: nil, session_id: nil
|
|
3126
|
-
|
|
3405
|
+
create_session: nil, session_id: nil, date_format: nil, datetime_format: nil,
|
|
3406
|
+
time_format: nil, timestamp_format: nil, null_markers: nil, source_column_match: nil,
|
|
3407
|
+
time_zone: nil, reference_file_schema_uri: nil, preserve_ascii_control_characters: nil,
|
|
3408
|
+
reservation: nil
|
|
3409
|
+
new_job = load_job_gapi table_id, dryrun, job_id: job_id, prefix: prefix, reservation: reservation
|
|
3127
3410
|
LoadJob::Updater.new(new_job).tap do |job|
|
|
3128
3411
|
job.location = location if location # may be table reference
|
|
3129
3412
|
job.create = create unless create.nil?
|
|
@@ -3143,7 +3426,16 @@ module Google
|
|
|
3143
3426
|
max_bad_records: max_bad_records,
|
|
3144
3427
|
quote: quote,
|
|
3145
3428
|
skip_leading: skip_leading,
|
|
3146
|
-
null_marker: null_marker
|
|
3429
|
+
null_marker: null_marker,
|
|
3430
|
+
date_format: date_format,
|
|
3431
|
+
datetime_format: datetime_format,
|
|
3432
|
+
time_format: time_format,
|
|
3433
|
+
timestamp_format: timestamp_format,
|
|
3434
|
+
null_markers: null_markers,
|
|
3435
|
+
source_column_match: source_column_match,
|
|
3436
|
+
time_zone: time_zone,
|
|
3437
|
+
reference_file_schema_uri: reference_file_schema_uri,
|
|
3438
|
+
preserve_ascii_control_characters: preserve_ascii_control_characters
|
|
3147
3439
|
end
|
|
3148
3440
|
end
|
|
3149
3441
|
|
|
@@ -3538,7 +3830,7 @@ module Google
|
|
|
3538
3830
|
# At most 1 policy tag is currently allowed.
|
|
3539
3831
|
# @param [Integer] max_length The maximum UTF-8 length of strings
|
|
3540
3832
|
# allowed in the field.
|
|
3541
|
-
# @param
|
|
3833
|
+
# @param [String] default_value_expression The default value of a field
|
|
3542
3834
|
# using a SQL expression. It can only be set for top level fields (columns).
|
|
3543
3835
|
# Use a struct or array expression to specify default value for the entire struct or
|
|
3544
3836
|
# array. The valid SQL expressions are:
|
|
@@ -3554,6 +3846,11 @@ module Google
|
|
|
3554
3846
|
# `ST_GEOPOINT`
|
|
3555
3847
|
# - Struct or array composed with the above allowed functions, for example:
|
|
3556
3848
|
# "[CURRENT_DATE(), DATE '2020-01-01'"]
|
|
3849
|
+
# @param [String] collation The collation of the field.
|
|
3850
|
+
# Collation can be set only when the type of field is `STRING`.
|
|
3851
|
+
# The following values are supported:
|
|
3852
|
+
# - `und:ci`: undetermined locale, case insensitive.
|
|
3853
|
+
# - (empty string): Default to case-sensitive behavior.
|
|
3557
3854
|
#
|
|
3558
3855
|
# @example
|
|
3559
3856
|
# require "google/cloud/bigquery"
|
|
@@ -3575,9 +3872,9 @@ module Google
|
|
|
3575
3872
|
#
|
|
3576
3873
|
# @!group Schema
|
|
3577
3874
|
def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil,
|
|
3578
|
-
default_value_expression: nil
|
|
3875
|
+
default_value_expression: nil, collation: nil
|
|
3579
3876
|
schema.string name, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length,
|
|
3580
|
-
default_value_expression: default_value_expression
|
|
3877
|
+
default_value_expression: default_value_expression, collation: collation
|
|
3581
3878
|
end
|
|
3582
3879
|
|
|
3583
3880
|
##
|