google-cloud-bigquery 1.21.2
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 +7 -0
- data/.yardopts +16 -0
- data/AUTHENTICATION.md +158 -0
- data/CHANGELOG.md +397 -0
- data/CODE_OF_CONDUCT.md +40 -0
- data/CONTRIBUTING.md +188 -0
- data/LICENSE +201 -0
- data/LOGGING.md +27 -0
- data/OVERVIEW.md +463 -0
- data/TROUBLESHOOTING.md +31 -0
- data/lib/google-cloud-bigquery.rb +139 -0
- data/lib/google/cloud/bigquery.rb +145 -0
- data/lib/google/cloud/bigquery/argument.rb +197 -0
- data/lib/google/cloud/bigquery/convert.rb +383 -0
- data/lib/google/cloud/bigquery/copy_job.rb +316 -0
- data/lib/google/cloud/bigquery/credentials.rb +50 -0
- data/lib/google/cloud/bigquery/data.rb +526 -0
- data/lib/google/cloud/bigquery/dataset.rb +2845 -0
- data/lib/google/cloud/bigquery/dataset/access.rb +1021 -0
- data/lib/google/cloud/bigquery/dataset/list.rb +162 -0
- data/lib/google/cloud/bigquery/encryption_configuration.rb +123 -0
- data/lib/google/cloud/bigquery/external.rb +2432 -0
- data/lib/google/cloud/bigquery/extract_job.rb +368 -0
- data/lib/google/cloud/bigquery/insert_response.rb +180 -0
- data/lib/google/cloud/bigquery/job.rb +657 -0
- data/lib/google/cloud/bigquery/job/list.rb +162 -0
- data/lib/google/cloud/bigquery/load_job.rb +1704 -0
- data/lib/google/cloud/bigquery/model.rb +740 -0
- data/lib/google/cloud/bigquery/model/list.rb +164 -0
- data/lib/google/cloud/bigquery/project.rb +1655 -0
- data/lib/google/cloud/bigquery/project/list.rb +161 -0
- data/lib/google/cloud/bigquery/query_job.rb +1695 -0
- data/lib/google/cloud/bigquery/routine.rb +1108 -0
- data/lib/google/cloud/bigquery/routine/list.rb +165 -0
- data/lib/google/cloud/bigquery/schema.rb +564 -0
- data/lib/google/cloud/bigquery/schema/field.rb +668 -0
- data/lib/google/cloud/bigquery/service.rb +589 -0
- data/lib/google/cloud/bigquery/standard_sql.rb +495 -0
- data/lib/google/cloud/bigquery/table.rb +3340 -0
- data/lib/google/cloud/bigquery/table/async_inserter.rb +520 -0
- data/lib/google/cloud/bigquery/table/list.rb +172 -0
- data/lib/google/cloud/bigquery/time.rb +65 -0
- data/lib/google/cloud/bigquery/version.rb +22 -0
- metadata +297 -0
data/TROUBLESHOOTING.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Troubleshooting
|
2
|
+
|
3
|
+
## Where can I get more help?
|
4
|
+
|
5
|
+
### Ask the Community
|
6
|
+
|
7
|
+
If you have a question about how to use a Google Cloud client library in your
|
8
|
+
project or are stuck in the Developer's console and don't know where to turn,
|
9
|
+
it's possible your questions have already been addressed by the community.
|
10
|
+
|
11
|
+
First, check out the appropriate tags on StackOverflow:
|
12
|
+
- [`google-cloud-platform+ruby+bigquery`][so-ruby]
|
13
|
+
|
14
|
+
Next, try searching through the issues on GitHub:
|
15
|
+
|
16
|
+
- [`api:bigquery` issues][gh-search-ruby]
|
17
|
+
|
18
|
+
Still nothing?
|
19
|
+
|
20
|
+
### Ask the Developers
|
21
|
+
|
22
|
+
If you're experiencing a bug with the code, or have an idea for how it can be
|
23
|
+
improved, *please* create a new issue on GitHub so we can talk about it.
|
24
|
+
|
25
|
+
- [New issue][gh-ruby]
|
26
|
+
|
27
|
+
[so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+bigquery
|
28
|
+
|
29
|
+
[gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+bigquery%22
|
30
|
+
|
31
|
+
[gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# Copyright 2016 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
##
|
16
|
+
# This file is here to be autorequired by bundler, so that the
|
17
|
+
# Google::Cloud.bigquery and Google::Cloud#bigquery methods can be available,
|
18
|
+
# but the library and all dependencies won't be loaded until required and used.
|
19
|
+
|
20
|
+
|
21
|
+
gem "google-cloud-core"
|
22
|
+
require "google/cloud" unless defined? Google::Cloud.new
|
23
|
+
require "google/cloud/config"
|
24
|
+
require "googleauth"
|
25
|
+
|
26
|
+
module Google
|
27
|
+
module Cloud
|
28
|
+
##
|
29
|
+
# Creates a new object for connecting to the BigQuery service.
|
30
|
+
# Each call creates a new connection.
|
31
|
+
#
|
32
|
+
# For more information on connecting to Google Cloud see the
|
33
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
34
|
+
#
|
35
|
+
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
36
|
+
# set of resources and operations that the connection can access. See
|
37
|
+
# [Using OAuth 2.0 to Access Google
|
38
|
+
# APIs](https://developers.google.com/identity/protocols/OAuth2).
|
39
|
+
#
|
40
|
+
# The default scope is:
|
41
|
+
#
|
42
|
+
# * `https://www.googleapis.com/auth/bigquery`
|
43
|
+
# @param [Integer] retries Number of times to retry requests on server
|
44
|
+
# error. The default value is `5`. Optional.
|
45
|
+
# @param [Integer] timeout Default request timeout in seconds. Optional.
|
46
|
+
#
|
47
|
+
# @return [Google::Cloud::Bigquery::Project]
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# require "google/cloud"
|
51
|
+
#
|
52
|
+
# gcloud = Google::Cloud.new
|
53
|
+
# bigquery = gcloud.bigquery
|
54
|
+
# dataset = bigquery.dataset "my_dataset"
|
55
|
+
# table = dataset.table "my_table"
|
56
|
+
#
|
57
|
+
# data = table.data
|
58
|
+
#
|
59
|
+
# # Iterate over the first page of results
|
60
|
+
# data.each do |row|
|
61
|
+
# puts row[:name]
|
62
|
+
# end
|
63
|
+
# # Retrieve the next page of results
|
64
|
+
# data = data.next if data.next?
|
65
|
+
#
|
66
|
+
# @example The default scope can be overridden with the `scope` option:
|
67
|
+
# require "google/cloud"
|
68
|
+
#
|
69
|
+
# gcloud = Google::Cloud.new
|
70
|
+
# platform_scope = "https://www.googleapis.com/auth/cloud-platform"
|
71
|
+
# bigquery = gcloud.bigquery scope: platform_scope
|
72
|
+
#
|
73
|
+
def bigquery scope: nil, retries: nil, timeout: nil
|
74
|
+
Google::Cloud.bigquery @project, @keyfile, scope: scope,
|
75
|
+
retries: (retries || @retries),
|
76
|
+
timeout: (timeout || @timeout)
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Creates a new `Project` instance connected to the BigQuery service.
|
81
|
+
# Each call creates a new connection.
|
82
|
+
#
|
83
|
+
# For more information on connecting to Google Cloud see the
|
84
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
85
|
+
#
|
86
|
+
# @param [String] project_id Identifier for a BigQuery project. If not
|
87
|
+
# present, the default project for the credentials is used.
|
88
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
89
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
90
|
+
# Google::Auth::Credentials object. (See {Bigquery::Credentials})
|
91
|
+
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
92
|
+
# set of resources and operations that the connection can access. See
|
93
|
+
# [Using OAuth 2.0 to Access Google
|
94
|
+
# APIs](https://developers.google.com/identity/protocols/OAuth2).
|
95
|
+
#
|
96
|
+
# The default scope is:
|
97
|
+
#
|
98
|
+
# * `https://www.googleapis.com/auth/bigquery`
|
99
|
+
# @param [Integer] retries Number of times to retry requests on server
|
100
|
+
# error. The default value is `5`. Optional.
|
101
|
+
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
102
|
+
#
|
103
|
+
# @return [Google::Cloud::Bigquery::Project]
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
# require "google/cloud"
|
107
|
+
#
|
108
|
+
# bigquery = Google::Cloud.bigquery
|
109
|
+
# dataset = bigquery.dataset "my_dataset"
|
110
|
+
# table = dataset.table "my_table"
|
111
|
+
#
|
112
|
+
def self.bigquery project_id = nil, credentials = nil, scope: nil, retries: nil, timeout: nil
|
113
|
+
require "google/cloud/bigquery"
|
114
|
+
Google::Cloud::Bigquery.new project_id: project_id, credentials: credentials,
|
115
|
+
scope: scope, retries: retries, timeout: timeout
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Set the default bigquery configuration
|
121
|
+
Google::Cloud.configure.add_config! :bigquery do |config|
|
122
|
+
default_project = Google::Cloud::Config.deferred do
|
123
|
+
ENV["BIGQUERY_PROJECT"]
|
124
|
+
end
|
125
|
+
default_creds = Google::Cloud::Config.deferred do
|
126
|
+
Google::Cloud::Config.credentials_from_env(
|
127
|
+
"BIGQUERY_CREDENTIALS", "BIGQUERY_CREDENTIALS_JSON", "BIGQUERY_KEYFILE", "BIGQUERY_KEYFILE_JSON"
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
config.add_field! :project_id, default_project, match: String, allow_nil: true
|
132
|
+
config.add_alias! :project, :project_id
|
133
|
+
config.add_field! :credentials, default_creds, match: [String, Hash, Google::Auth::Credentials], allow_nil: true
|
134
|
+
config.add_alias! :keyfile, :credentials
|
135
|
+
config.add_field! :scope, nil, match: [String, Array]
|
136
|
+
config.add_field! :retries, nil, match: Integer
|
137
|
+
config.add_field! :timeout, nil, match: Integer
|
138
|
+
config.add_field! :endpoint, nil, match: String
|
139
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# Copyright 2015 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "google-cloud-bigquery"
|
17
|
+
require "google/cloud/bigquery/project"
|
18
|
+
require "google/cloud/config"
|
19
|
+
require "google/cloud/env"
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Cloud
|
23
|
+
##
|
24
|
+
# # Google Cloud BigQuery
|
25
|
+
#
|
26
|
+
# Google BigQuery enables super-fast, SQL-like queries against massive
|
27
|
+
# datasets, using the processing power of Google's infrastructure.
|
28
|
+
#
|
29
|
+
# See {file:OVERVIEW.md BigQuery Overview}.
|
30
|
+
#
|
31
|
+
module Bigquery
|
32
|
+
# Creates a new `Project` instance connected to the BigQuery service.
|
33
|
+
# Each call creates a new connection.
|
34
|
+
#
|
35
|
+
# For more information on connecting to Google Cloud see the
|
36
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
37
|
+
#
|
38
|
+
# @param [String] project_id Identifier for a BigQuery project. If not
|
39
|
+
# present, the default project for the credentials is used.
|
40
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
41
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
42
|
+
# Google::Auth::Credentials object. (See {Bigquery::Credentials})
|
43
|
+
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
44
|
+
# the set of resources and operations that the connection can access.
|
45
|
+
# See # [Using OAuth 2.0 to Access Google #
|
46
|
+
# APIs](https://developers.google.com/identity/protocols/OAuth2).
|
47
|
+
#
|
48
|
+
# The default scope is:
|
49
|
+
#
|
50
|
+
# * `https://www.googleapis.com/auth/bigquery`
|
51
|
+
# @param [Integer] retries Number of times to retry requests on server
|
52
|
+
# error. The default value is `5`. Optional.
|
53
|
+
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
54
|
+
# @param [String] endpoint Override of the endpoint host name. Optional.
|
55
|
+
# If the param is nil, uses the default endpoint.
|
56
|
+
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
57
|
+
# @param [String] keyfile Alias for the `credentials` argument.
|
58
|
+
# Deprecated.
|
59
|
+
#
|
60
|
+
# @return [Google::Cloud::Bigquery::Project]
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
# require "google/cloud/bigquery"
|
64
|
+
#
|
65
|
+
# bigquery = Google::Cloud::Bigquery.new
|
66
|
+
# dataset = bigquery.dataset "my_dataset"
|
67
|
+
# table = dataset.table "my_table"
|
68
|
+
#
|
69
|
+
def self.new project_id: nil, credentials: nil, scope: nil, retries: nil, timeout: nil, endpoint: nil,
|
70
|
+
project: nil, keyfile: nil
|
71
|
+
scope ||= configure.scope
|
72
|
+
retries ||= configure.retries
|
73
|
+
timeout ||= configure.timeout
|
74
|
+
endpoint ||= configure.endpoint
|
75
|
+
credentials ||= (keyfile || default_credentials(scope: scope))
|
76
|
+
|
77
|
+
unless credentials.is_a? Google::Auth::Credentials
|
78
|
+
credentials = Bigquery::Credentials.new credentials, scope: scope
|
79
|
+
end
|
80
|
+
|
81
|
+
project_id = resolve_project_id(project_id || project, credentials)
|
82
|
+
raise ArgumentError, "project_id is missing" if project_id.empty?
|
83
|
+
|
84
|
+
Bigquery::Project.new(
|
85
|
+
Bigquery::Service.new(
|
86
|
+
project_id, credentials,
|
87
|
+
retries: retries, timeout: timeout, host: endpoint
|
88
|
+
)
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
##
|
93
|
+
# Configure the Google Cloud BigQuery library.
|
94
|
+
#
|
95
|
+
# The following BigQuery configuration parameters are supported:
|
96
|
+
#
|
97
|
+
# * `project_id` - (String) Identifier for a BigQuery project. (The
|
98
|
+
# parameter `project` is considered deprecated, but may also be used.)
|
99
|
+
# * `credentials` - (String, Hash, Google::Auth::Credentials) The path to
|
100
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
101
|
+
# Google::Auth::Credentials object. (See {Bigquery::Credentials}) (The
|
102
|
+
# parameter `keyfile` is considered deprecated, but may also be used.)
|
103
|
+
# * `endpoint` - (String) Override of the endpoint host name, or `nil`
|
104
|
+
# to use the default endpoint.
|
105
|
+
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
|
106
|
+
# the set of resources and operations that the connection can access.
|
107
|
+
# * `retries` - (Integer) Number of times to retry requests on server
|
108
|
+
# error.
|
109
|
+
# * `timeout` - (Integer) Default timeout to use in requests.
|
110
|
+
#
|
111
|
+
# @return [Google::Cloud::Config] The configuration object the
|
112
|
+
# Google::Cloud::Bigquery library uses.
|
113
|
+
#
|
114
|
+
def self.configure
|
115
|
+
yield Google::Cloud.configure.bigquery if block_given?
|
116
|
+
|
117
|
+
Google::Cloud.configure.bigquery
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# @private Resolve project.
|
122
|
+
def self.resolve_project_id given_project, credentials
|
123
|
+
project_id = given_project || default_project_id
|
124
|
+
project_id ||= credentials.project_id if credentials.respond_to? :project_id
|
125
|
+
project_id.to_s # Always cast to a string
|
126
|
+
end
|
127
|
+
|
128
|
+
##
|
129
|
+
# @private Default project.
|
130
|
+
def self.default_project_id
|
131
|
+
Google::Cloud.configure.bigquery.project_id ||
|
132
|
+
Google::Cloud.configure.project_id ||
|
133
|
+
Google::Cloud.env.project_id
|
134
|
+
end
|
135
|
+
|
136
|
+
##
|
137
|
+
# @private Default credentials.
|
138
|
+
def self.default_credentials scope: nil
|
139
|
+
Google::Cloud.configure.bigquery.credentials ||
|
140
|
+
Google::Cloud.configure.credentials ||
|
141
|
+
Bigquery::Credentials.default(scope: scope)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "google/cloud/bigquery/standard_sql"
|
17
|
+
|
18
|
+
module Google
|
19
|
+
module Cloud
|
20
|
+
module Bigquery
|
21
|
+
##
|
22
|
+
# # Argument
|
23
|
+
#
|
24
|
+
# Input/output argument of a function or a stored procedure. See {Routine}.
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# require "google/cloud/bigquery"
|
28
|
+
#
|
29
|
+
# bigquery = Google::Cloud::Bigquery.new
|
30
|
+
# dataset = bigquery.dataset "my_dataset"
|
31
|
+
# routine = dataset.create_routine "my_routine" do |r|
|
32
|
+
# r.routine_type = "SCALAR_FUNCTION"
|
33
|
+
# r.language = :SQL
|
34
|
+
# r.body = "(SELECT SUM(IF(elem.name = \"foo\",elem.val,null)) FROM UNNEST(arr) AS elem)"
|
35
|
+
# r.arguments = [
|
36
|
+
# Google::Cloud::Bigquery::Argument.new(
|
37
|
+
# name: "arr",
|
38
|
+
# argument_kind: "FIXED_TYPE",
|
39
|
+
# data_type: Google::Cloud::Bigquery::StandardSql::DataType.new(
|
40
|
+
# type_kind: "ARRAY",
|
41
|
+
# array_element_type: Google::Cloud::Bigquery::StandardSql::DataType.new(
|
42
|
+
# type_kind: "STRUCT",
|
43
|
+
# struct_type: Google::Cloud::Bigquery::StandardSql::StructType.new(
|
44
|
+
# fields: [
|
45
|
+
# Google::Cloud::Bigquery::StandardSql::Field.new(
|
46
|
+
# name: "name",
|
47
|
+
# type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: "STRING")
|
48
|
+
# ),
|
49
|
+
# Google::Cloud::Bigquery::StandardSql::Field.new(
|
50
|
+
# name: "val",
|
51
|
+
# type: Google::Cloud::Bigquery::StandardSql::DataType.new(type_kind: "INT64")
|
52
|
+
# )
|
53
|
+
# ]
|
54
|
+
# )
|
55
|
+
# )
|
56
|
+
# )
|
57
|
+
# )
|
58
|
+
# ]
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
class Argument
|
62
|
+
##
|
63
|
+
# Creates a new, immutable Argument object.
|
64
|
+
#
|
65
|
+
# @overload initialize(data_type, kind, mode, name)
|
66
|
+
# @param [StandardSql::DataType, String] data_type The data type of the argument. Required unless
|
67
|
+
# {#argument_kind} is `ANY_TYPE`.
|
68
|
+
# @param [String] argument_kind The kind of argument. Optional. Defaults to `FIXED_TYPE`.
|
69
|
+
#
|
70
|
+
# * `FIXED_TYPE` - The argument is a variable with fully specified type, which can be a struct or an array,
|
71
|
+
# but not a table.
|
72
|
+
# * `ANY_TYPE` - The argument is any type, including struct or array, but not a table.
|
73
|
+
#
|
74
|
+
# To be added: `FIXED_TABLE`, `ANY_TABLE`.
|
75
|
+
# @param [String] mode Specifies whether the argument is input or output. Optional. Can be set for procedures
|
76
|
+
# only.
|
77
|
+
#
|
78
|
+
# * IN - The argument is input-only.
|
79
|
+
# * OUT - The argument is output-only.
|
80
|
+
# * INOUT - The argument is both an input and an output.
|
81
|
+
# @param [String] name The name of the argument. Optional. Can be absent for a function return argument.
|
82
|
+
#
|
83
|
+
def initialize **kwargs
|
84
|
+
kwargs[:data_type] = StandardSql::DataType.gapi_from_string_or_data_type kwargs[:data_type]
|
85
|
+
@gapi = Google::Apis::BigqueryV2::Argument.new(**kwargs)
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# The data type of the argument. Required unless {#argument_kind} is `ANY_TYPE`.
|
90
|
+
#
|
91
|
+
# @return [StandardSql::DataType] The data type.
|
92
|
+
#
|
93
|
+
def data_type
|
94
|
+
StandardSql::DataType.from_gapi @gapi.data_type
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# The kind of argument. Optional. Defaults to `FIXED_TYPE`.
|
99
|
+
#
|
100
|
+
# * `FIXED_TYPE` - The argument is a variable with fully specified type, which can be a struct or an array, but
|
101
|
+
# not a table.
|
102
|
+
# * `ANY_TYPE` - The argument is any type, including struct or array, but not a table.
|
103
|
+
#
|
104
|
+
# To be added: `FIXED_TABLE`, `ANY_TABLE`.
|
105
|
+
#
|
106
|
+
# @return [String] The upper case kind of argument.
|
107
|
+
#
|
108
|
+
def argument_kind
|
109
|
+
@gapi.argument_kind
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Checks if the value of {#argument_kind} is `FIXED_TYPE`. The default is `true`.
|
114
|
+
#
|
115
|
+
# @return [Boolean] `true` when `FIXED_TYPE`, `false` otherwise.
|
116
|
+
#
|
117
|
+
def fixed_type?
|
118
|
+
return true if @gapi.argument_kind.nil?
|
119
|
+
@gapi.argument_kind == "FIXED_TYPE"
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Checks if the value of {#argument_kind} is `ANY_TYPE`. The default is `false`.
|
124
|
+
#
|
125
|
+
# @return [Boolean] `true` when `ANY_TYPE`, `false` otherwise.
|
126
|
+
#
|
127
|
+
def any_type?
|
128
|
+
@gapi.argument_kind == "ANY_TYPE"
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Specifies whether the argument is input or output. Optional. Can be set for procedures only.
|
133
|
+
#
|
134
|
+
# * IN - The argument is input-only.
|
135
|
+
# * OUT - The argument is output-only.
|
136
|
+
# * INOUT - The argument is both an input and an output.
|
137
|
+
#
|
138
|
+
# @return [String] The upper case input/output mode of the argument.
|
139
|
+
#
|
140
|
+
def mode
|
141
|
+
@gapi.mode
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# Checks if the value of {#mode} is `IN`. Can be set for procedures only. The default is `false`.
|
146
|
+
#
|
147
|
+
# @return [Boolean] `true` when `IN`, `false` otherwise.
|
148
|
+
#
|
149
|
+
def in?
|
150
|
+
@gapi.mode == "IN"
|
151
|
+
end
|
152
|
+
|
153
|
+
##
|
154
|
+
# Checks if the value of {#mode} is `OUT`. Can be set for procedures only. The default is `false`.
|
155
|
+
#
|
156
|
+
# @return [Boolean] `true` when `OUT`, `false` otherwise.
|
157
|
+
#
|
158
|
+
def out?
|
159
|
+
@gapi.mode == "OUT"
|
160
|
+
end
|
161
|
+
|
162
|
+
##
|
163
|
+
# Checks if the value of {#mode} is `INOUT`. Can be set for procedures only. The default is `false`.
|
164
|
+
#
|
165
|
+
# @return [Boolean] `true` when `INOUT`, `false` otherwise.
|
166
|
+
#
|
167
|
+
def inout?
|
168
|
+
@gapi.mode == "INOUT"
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
#
|
173
|
+
# The name of the argument. Optional. Can be absent for a function return argument.
|
174
|
+
#
|
175
|
+
# @return [String] The name of the argument.
|
176
|
+
#
|
177
|
+
def name
|
178
|
+
@gapi.name
|
179
|
+
end
|
180
|
+
|
181
|
+
##
|
182
|
+
# @private
|
183
|
+
def to_gapi
|
184
|
+
@gapi
|
185
|
+
end
|
186
|
+
|
187
|
+
##
|
188
|
+
# @private New Argument from a Google API Client object.
|
189
|
+
def self.from_gapi gapi
|
190
|
+
new.tap do |a|
|
191
|
+
a.instance_variable_set :@gapi, gapi
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|