blob: 229ee5240e68bc4fe8dded37e2774e754527c415 [file] [log] [blame]
Bu Sun Kim715bd7f2019-06-14 16:50:42 -07001<html><body>
2<style>
3
4body, h1, h2, h3, div, span, p, pre, a {
5 margin: 0;
6 padding: 0;
7 border: 0;
8 font-weight: inherit;
9 font-style: inherit;
10 font-size: 100%;
11 font-family: inherit;
12 vertical-align: baseline;
13}
14
15body {
16 font-size: 13px;
17 padding: 1em;
18}
19
20h1 {
21 font-size: 26px;
22 margin-bottom: 1em;
23}
24
25h2 {
26 font-size: 24px;
27 margin-bottom: 1em;
28}
29
30h3 {
31 font-size: 20px;
32 margin-bottom: 1em;
33 margin-top: 1em;
34}
35
36pre, code {
37 line-height: 1.5;
38 font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace;
39}
40
41pre {
42 margin-top: 0.5em;
43}
44
45h1, h2, h3, p {
46 font-family: Arial, sans serif;
47}
48
49h1, h2, h3 {
50 border-bottom: solid #CCC 1px;
51}
52
53.toc_element {
54 margin-top: 0.5em;
55}
56
57.firstline {
58 margin-left: 2 em;
59}
60
61.method {
62 margin-top: 1em;
63 border: solid 1px #CCC;
64 padding: 1em;
65 background: #EEE;
66}
67
68.details {
69 font-weight: bold;
70 font-size: 14px;
71}
72
73</style>
74
75<h1><a href="bigquery_v2.html">BigQuery API</a> . <a href="bigquery_v2.routines.html">routines</a></h1>
76<h2>Instance Methods</h2>
77<p class="toc_element">
78 <code><a href="#delete">delete(projectId, datasetId, routineId)</a></code></p>
79<p class="firstline">Deletes the routine specified by routineId from the dataset.</p>
80<p class="toc_element">
Dan O'Mearadd494642020-05-01 07:42:23 -070081 <code><a href="#get">get(projectId, datasetId, routineId, readMask=None)</a></code></p>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -070082<p class="firstline">Gets the specified routine resource by routine ID.</p>
83<p class="toc_element">
Dan O'Mearadd494642020-05-01 07:42:23 -070084 <code><a href="#insert">insert(projectId, datasetId, body=None)</a></code></p>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -070085<p class="firstline">Creates a new routine in the dataset.</p>
86<p class="toc_element">
Bu Sun Kim65020912020-05-20 12:08:20 -070087 <code><a href="#list">list(projectId, datasetId, readMask=None, filter=None, pageToken=None, maxResults=None)</a></code></p>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -070088<p class="firstline">Lists all routines in the specified dataset. Requires the READER dataset</p>
89<p class="toc_element">
90 <code><a href="#list_next">list_next(previous_request, previous_response)</a></code></p>
91<p class="firstline">Retrieves the next page of results.</p>
92<p class="toc_element">
Dan O'Mearadd494642020-05-01 07:42:23 -070093 <code><a href="#update">update(projectId, datasetId, routineId, body=None)</a></code></p>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -070094<p class="firstline">Updates information in an existing routine. The update method replaces the</p>
95<h3>Method Details</h3>
96<div class="method">
97 <code class="details" id="delete">delete(projectId, datasetId, routineId)</code>
98 <pre>Deletes the routine specified by routineId from the dataset.
99
100Args:
Dan O'Mearadd494642020-05-01 07:42:23 -0700101 projectId: string, Required. Project ID of the routine to delete (required)
102 datasetId: string, Required. Dataset ID of the routine to delete (required)
103 routineId: string, Required. Routine ID of the routine to delete (required)
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700104</pre>
105</div>
106
107<div class="method">
Dan O'Mearadd494642020-05-01 07:42:23 -0700108 <code class="details" id="get">get(projectId, datasetId, routineId, readMask=None)</code>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700109 <pre>Gets the specified routine resource by routine ID.
110
111Args:
Dan O'Mearadd494642020-05-01 07:42:23 -0700112 projectId: string, Required. Project ID of the requested routine (required)
113 datasetId: string, Required. Dataset ID of the requested routine (required)
114 routineId: string, Required. Routine ID of the requested routine (required)
115 readMask: string, If set, only the Routine fields in the field mask are returned in the
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700116response. If unset, all Routine fields are returned.
117
118Returns:
119 An object of the form:
120
121 { # A user-defined function or a stored procedure.
Bu Sun Kim65020912020-05-20 12:08:20 -0700122 &quot;importedLibraries&quot;: [ # Optional. If language = &quot;JAVASCRIPT&quot;, this field stores the path of the
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700123 # imported JAVASCRIPT libraries.
Bu Sun Kim65020912020-05-20 12:08:20 -0700124 &quot;A String&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700125 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700126 &quot;lastModifiedTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was last modified, in milliseconds
127 # since the epoch.
128 &quot;returnType&quot;: { # The type of a variable, e.g., a function argument. # Optional if language = &quot;SQL&quot;; required otherwise.
Dan O'Mearadd494642020-05-01 07:42:23 -0700129 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700130 # If absent, the return type is inferred from definition_body at query time
131 # in each query that references this routine. If present, then the evaluated
132 # result will be cast to the specified returned type at query time.
133 #
Dan O'Mearadd494642020-05-01 07:42:23 -0700134 # For example, for the functions created with the following statements:
135 #
136 # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);`
137 #
138 # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));`
139 #
140 # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));`
141 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700142 # The return_type is `{type_kind: &quot;FLOAT64&quot;}` for `Add` and `Decrement`, and
Dan O'Mearadd494642020-05-01 07:42:23 -0700143 # is absent for `Increment` (inferred as FLOAT64 at query time).
144 #
145 # Suppose the function `Add` is replaced by
146 # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);`
147 #
148 # Then the inferred return type of `Increment` is automatically changed to
149 # INT64 at query time, while the return type of `Decrement` remains FLOAT64.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700150 # Examples:
Bu Sun Kim65020912020-05-20 12:08:20 -0700151 # INT64: {type_kind=&quot;INT64&quot;}
152 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
Dan O'Mearadd494642020-05-01 07:42:23 -0700153 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
Bu Sun Kim65020912020-05-20 12:08:20 -0700154 # {type_kind=&quot;STRUCT&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700155 # struct_type={fields=[
Bu Sun Kim65020912020-05-20 12:08:20 -0700156 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
157 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700158 # ]}}
Bu Sun Kim65020912020-05-20 12:08:20 -0700159 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
160 &quot;fields&quot;: [
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700161 # Object with schema name: StandardSqlField
162 ],
163 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700164 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
165 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
166 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700167 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700168 &quot;language&quot;: &quot;A String&quot;, # Optional. Defaults to &quot;SQL&quot;.
169 &quot;description&quot;: &quot;A String&quot;, # Optional. [Experimental] The description of the routine if defined.
170 &quot;etag&quot;: &quot;A String&quot;, # Output only. A hash of this resource.
171 &quot;definitionBody&quot;: &quot;A String&quot;, # Required. The body of the routine.
Dan O'Mearadd494642020-05-01 07:42:23 -0700172 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700173 # For functions, this is the expression in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700174 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700175 # If language=SQL, it is the substring inside (but excluding) the
176 # parentheses. For example, for the function created with the following
Dan O'Mearadd494642020-05-01 07:42:23 -0700177 # statement:
178 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700179 # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, &quot;\n&quot;, y))`
Dan O'Mearadd494642020-05-01 07:42:23 -0700180 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700181 # The definition_body is `concat(x, &quot;\n&quot;, y)` (\n is not replaced with
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700182 # linebreak).
Dan O'Mearadd494642020-05-01 07:42:23 -0700183 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700184 # If language=JAVASCRIPT, it is the evaluated string in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700185 # For example, for the function created with the following statement:
186 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700187 # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS &#x27;return &quot;\n&quot;;\n&#x27;`
Dan O'Mearadd494642020-05-01 07:42:23 -0700188 #
189 # The definition_body is
190 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700191 # `return &quot;\n&quot;;\n`
Dan O'Mearadd494642020-05-01 07:42:23 -0700192 #
193 # Note that both \n are replaced with linebreaks.
Bu Sun Kim65020912020-05-20 12:08:20 -0700194 &quot;creationTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was created, in milliseconds since
195 # the epoch.
196 &quot;routineType&quot;: &quot;A String&quot;, # Required. The type of routine.
197 &quot;routineReference&quot;: { # Required. Reference describing the ID of this routine.
198 &quot;projectId&quot;: &quot;A String&quot;, # [Required] The ID of the project containing this routine.
199 &quot;datasetId&quot;: &quot;A String&quot;, # [Required] The ID of the dataset containing this routine.
200 &quot;routineId&quot;: &quot;A String&quot;, # [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
201 },
202 &quot;arguments&quot;: [ # Optional.
203 { # Input/output argument of a function or a stored procedure.
204 &quot;name&quot;: &quot;A String&quot;, # Optional. The name of this argument. Can be absent for function return argument.
205 &quot;argumentKind&quot;: &quot;A String&quot;, # Optional. Defaults to FIXED_TYPE.
206 &quot;mode&quot;: &quot;A String&quot;, # Optional. Specifies whether the argument is input or output.
207 # Can be set for procedures only.
208 &quot;dataType&quot;: { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE.
209 # Examples:
210 # INT64: {type_kind=&quot;INT64&quot;}
211 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
212 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
213 # {type_kind=&quot;STRUCT&quot;,
214 # struct_type={fields=[
215 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
216 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
217 # ]}}
218 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
219 &quot;fields&quot;: [
220 # Object with schema name: StandardSqlField
221 ],
222 },
223 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
224 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
225 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
226 },
227 },
228 ],
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700229 }</pre>
230</div>
231
232<div class="method">
Dan O'Mearadd494642020-05-01 07:42:23 -0700233 <code class="details" id="insert">insert(projectId, datasetId, body=None)</code>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700234 <pre>Creates a new routine in the dataset.
235
236Args:
Dan O'Mearadd494642020-05-01 07:42:23 -0700237 projectId: string, Required. Project ID of the new routine (required)
238 datasetId: string, Required. Dataset ID of the new routine (required)
239 body: object, The request body.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700240 The object takes the form of:
241
242{ # A user-defined function or a stored procedure.
Bu Sun Kim65020912020-05-20 12:08:20 -0700243 &quot;importedLibraries&quot;: [ # Optional. If language = &quot;JAVASCRIPT&quot;, this field stores the path of the
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700244 # imported JAVASCRIPT libraries.
Bu Sun Kim65020912020-05-20 12:08:20 -0700245 &quot;A String&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700246 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700247 &quot;lastModifiedTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was last modified, in milliseconds
248 # since the epoch.
249 &quot;returnType&quot;: { # The type of a variable, e.g., a function argument. # Optional if language = &quot;SQL&quot;; required otherwise.
Dan O'Mearadd494642020-05-01 07:42:23 -0700250 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700251 # If absent, the return type is inferred from definition_body at query time
252 # in each query that references this routine. If present, then the evaluated
253 # result will be cast to the specified returned type at query time.
254 #
Dan O'Mearadd494642020-05-01 07:42:23 -0700255 # For example, for the functions created with the following statements:
256 #
257 # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);`
258 #
259 # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));`
260 #
261 # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));`
262 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700263 # The return_type is `{type_kind: &quot;FLOAT64&quot;}` for `Add` and `Decrement`, and
Dan O'Mearadd494642020-05-01 07:42:23 -0700264 # is absent for `Increment` (inferred as FLOAT64 at query time).
265 #
266 # Suppose the function `Add` is replaced by
267 # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);`
268 #
269 # Then the inferred return type of `Increment` is automatically changed to
270 # INT64 at query time, while the return type of `Decrement` remains FLOAT64.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700271 # Examples:
Bu Sun Kim65020912020-05-20 12:08:20 -0700272 # INT64: {type_kind=&quot;INT64&quot;}
273 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
Dan O'Mearadd494642020-05-01 07:42:23 -0700274 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
Bu Sun Kim65020912020-05-20 12:08:20 -0700275 # {type_kind=&quot;STRUCT&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700276 # struct_type={fields=[
Bu Sun Kim65020912020-05-20 12:08:20 -0700277 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
278 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700279 # ]}}
Bu Sun Kim65020912020-05-20 12:08:20 -0700280 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
281 &quot;fields&quot;: [
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700282 # Object with schema name: StandardSqlField
283 ],
284 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700285 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
286 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
287 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700288 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700289 &quot;language&quot;: &quot;A String&quot;, # Optional. Defaults to &quot;SQL&quot;.
290 &quot;description&quot;: &quot;A String&quot;, # Optional. [Experimental] The description of the routine if defined.
291 &quot;etag&quot;: &quot;A String&quot;, # Output only. A hash of this resource.
292 &quot;definitionBody&quot;: &quot;A String&quot;, # Required. The body of the routine.
Dan O'Mearadd494642020-05-01 07:42:23 -0700293 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700294 # For functions, this is the expression in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700295 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700296 # If language=SQL, it is the substring inside (but excluding) the
297 # parentheses. For example, for the function created with the following
Dan O'Mearadd494642020-05-01 07:42:23 -0700298 # statement:
299 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700300 # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, &quot;\n&quot;, y))`
Dan O'Mearadd494642020-05-01 07:42:23 -0700301 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700302 # The definition_body is `concat(x, &quot;\n&quot;, y)` (\n is not replaced with
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700303 # linebreak).
Dan O'Mearadd494642020-05-01 07:42:23 -0700304 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700305 # If language=JAVASCRIPT, it is the evaluated string in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700306 # For example, for the function created with the following statement:
307 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700308 # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS &#x27;return &quot;\n&quot;;\n&#x27;`
Dan O'Mearadd494642020-05-01 07:42:23 -0700309 #
310 # The definition_body is
311 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700312 # `return &quot;\n&quot;;\n`
Dan O'Mearadd494642020-05-01 07:42:23 -0700313 #
314 # Note that both \n are replaced with linebreaks.
Bu Sun Kim65020912020-05-20 12:08:20 -0700315 &quot;creationTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was created, in milliseconds since
316 # the epoch.
317 &quot;routineType&quot;: &quot;A String&quot;, # Required. The type of routine.
318 &quot;routineReference&quot;: { # Required. Reference describing the ID of this routine.
319 &quot;projectId&quot;: &quot;A String&quot;, # [Required] The ID of the project containing this routine.
320 &quot;datasetId&quot;: &quot;A String&quot;, # [Required] The ID of the dataset containing this routine.
321 &quot;routineId&quot;: &quot;A String&quot;, # [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
322 },
323 &quot;arguments&quot;: [ # Optional.
324 { # Input/output argument of a function or a stored procedure.
325 &quot;name&quot;: &quot;A String&quot;, # Optional. The name of this argument. Can be absent for function return argument.
326 &quot;argumentKind&quot;: &quot;A String&quot;, # Optional. Defaults to FIXED_TYPE.
327 &quot;mode&quot;: &quot;A String&quot;, # Optional. Specifies whether the argument is input or output.
328 # Can be set for procedures only.
329 &quot;dataType&quot;: { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE.
330 # Examples:
331 # INT64: {type_kind=&quot;INT64&quot;}
332 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
333 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
334 # {type_kind=&quot;STRUCT&quot;,
335 # struct_type={fields=[
336 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
337 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
338 # ]}}
339 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
340 &quot;fields&quot;: [
341 # Object with schema name: StandardSqlField
342 ],
343 },
344 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
345 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
346 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
347 },
348 },
349 ],
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700350 }
351
352
353Returns:
354 An object of the form:
355
356 { # A user-defined function or a stored procedure.
Bu Sun Kim65020912020-05-20 12:08:20 -0700357 &quot;importedLibraries&quot;: [ # Optional. If language = &quot;JAVASCRIPT&quot;, this field stores the path of the
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700358 # imported JAVASCRIPT libraries.
Bu Sun Kim65020912020-05-20 12:08:20 -0700359 &quot;A String&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700360 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700361 &quot;lastModifiedTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was last modified, in milliseconds
362 # since the epoch.
363 &quot;returnType&quot;: { # The type of a variable, e.g., a function argument. # Optional if language = &quot;SQL&quot;; required otherwise.
Dan O'Mearadd494642020-05-01 07:42:23 -0700364 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700365 # If absent, the return type is inferred from definition_body at query time
366 # in each query that references this routine. If present, then the evaluated
367 # result will be cast to the specified returned type at query time.
368 #
Dan O'Mearadd494642020-05-01 07:42:23 -0700369 # For example, for the functions created with the following statements:
370 #
371 # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);`
372 #
373 # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));`
374 #
375 # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));`
376 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700377 # The return_type is `{type_kind: &quot;FLOAT64&quot;}` for `Add` and `Decrement`, and
Dan O'Mearadd494642020-05-01 07:42:23 -0700378 # is absent for `Increment` (inferred as FLOAT64 at query time).
379 #
380 # Suppose the function `Add` is replaced by
381 # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);`
382 #
383 # Then the inferred return type of `Increment` is automatically changed to
384 # INT64 at query time, while the return type of `Decrement` remains FLOAT64.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700385 # Examples:
Bu Sun Kim65020912020-05-20 12:08:20 -0700386 # INT64: {type_kind=&quot;INT64&quot;}
387 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
Dan O'Mearadd494642020-05-01 07:42:23 -0700388 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
Bu Sun Kim65020912020-05-20 12:08:20 -0700389 # {type_kind=&quot;STRUCT&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700390 # struct_type={fields=[
Bu Sun Kim65020912020-05-20 12:08:20 -0700391 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
392 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700393 # ]}}
Bu Sun Kim65020912020-05-20 12:08:20 -0700394 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
395 &quot;fields&quot;: [
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700396 # Object with schema name: StandardSqlField
397 ],
398 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700399 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
400 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
401 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700402 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700403 &quot;language&quot;: &quot;A String&quot;, # Optional. Defaults to &quot;SQL&quot;.
404 &quot;description&quot;: &quot;A String&quot;, # Optional. [Experimental] The description of the routine if defined.
405 &quot;etag&quot;: &quot;A String&quot;, # Output only. A hash of this resource.
406 &quot;definitionBody&quot;: &quot;A String&quot;, # Required. The body of the routine.
Dan O'Mearadd494642020-05-01 07:42:23 -0700407 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700408 # For functions, this is the expression in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700409 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700410 # If language=SQL, it is the substring inside (but excluding) the
411 # parentheses. For example, for the function created with the following
Dan O'Mearadd494642020-05-01 07:42:23 -0700412 # statement:
413 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700414 # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, &quot;\n&quot;, y))`
Dan O'Mearadd494642020-05-01 07:42:23 -0700415 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700416 # The definition_body is `concat(x, &quot;\n&quot;, y)` (\n is not replaced with
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700417 # linebreak).
Dan O'Mearadd494642020-05-01 07:42:23 -0700418 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700419 # If language=JAVASCRIPT, it is the evaluated string in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700420 # For example, for the function created with the following statement:
421 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700422 # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS &#x27;return &quot;\n&quot;;\n&#x27;`
Dan O'Mearadd494642020-05-01 07:42:23 -0700423 #
424 # The definition_body is
425 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700426 # `return &quot;\n&quot;;\n`
Dan O'Mearadd494642020-05-01 07:42:23 -0700427 #
428 # Note that both \n are replaced with linebreaks.
Bu Sun Kim65020912020-05-20 12:08:20 -0700429 &quot;creationTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was created, in milliseconds since
430 # the epoch.
431 &quot;routineType&quot;: &quot;A String&quot;, # Required. The type of routine.
432 &quot;routineReference&quot;: { # Required. Reference describing the ID of this routine.
433 &quot;projectId&quot;: &quot;A String&quot;, # [Required] The ID of the project containing this routine.
434 &quot;datasetId&quot;: &quot;A String&quot;, # [Required] The ID of the dataset containing this routine.
435 &quot;routineId&quot;: &quot;A String&quot;, # [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
436 },
437 &quot;arguments&quot;: [ # Optional.
438 { # Input/output argument of a function or a stored procedure.
439 &quot;name&quot;: &quot;A String&quot;, # Optional. The name of this argument. Can be absent for function return argument.
440 &quot;argumentKind&quot;: &quot;A String&quot;, # Optional. Defaults to FIXED_TYPE.
441 &quot;mode&quot;: &quot;A String&quot;, # Optional. Specifies whether the argument is input or output.
442 # Can be set for procedures only.
443 &quot;dataType&quot;: { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE.
444 # Examples:
445 # INT64: {type_kind=&quot;INT64&quot;}
446 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
447 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
448 # {type_kind=&quot;STRUCT&quot;,
449 # struct_type={fields=[
450 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
451 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
452 # ]}}
453 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
454 &quot;fields&quot;: [
455 # Object with schema name: StandardSqlField
456 ],
457 },
458 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
459 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
460 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
461 },
462 },
463 ],
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700464 }</pre>
465</div>
466
467<div class="method">
Bu Sun Kim65020912020-05-20 12:08:20 -0700468 <code class="details" id="list">list(projectId, datasetId, readMask=None, filter=None, pageToken=None, maxResults=None)</code>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700469 <pre>Lists all routines in the specified dataset. Requires the READER dataset
470role.
471
472Args:
Dan O'Mearadd494642020-05-01 07:42:23 -0700473 projectId: string, Required. Project ID of the routines to list (required)
474 datasetId: string, Required. Dataset ID of the routines to list (required)
Dan O'Mearadd494642020-05-01 07:42:23 -0700475 readMask: string, If set, then only the Routine fields in the field mask, as well as
476project_id, dataset_id and routine_id, are returned in the response.
477If unset, then the following Routine fields are returned:
478etag, project_id, dataset_id, routine_id, routine_type, creation_time,
479last_modified_time, and language.
Bu Sun Kim65020912020-05-20 12:08:20 -0700480 filter: string, If set, then only the Routines matching this filter are returned.
481The current supported form is either &quot;routine_type:&lt;RoutineType&gt;&quot; or
482&quot;routineType:&lt;RoutineType&gt;&quot;, where &lt;RoutineType&gt; is a RoutineType enum.
483Example: &quot;routineType:SCALAR_FUNCTION&quot;.
484 pageToken: string, Page token, returned by a previous call, to request the next page of
485results
486 maxResults: integer, The maximum number of results to return in a single response page.
487Leverage the page tokens to iterate through the entire collection.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700488
489Returns:
490 An object of the form:
491
492 {
Bu Sun Kim65020912020-05-20 12:08:20 -0700493 &quot;routines&quot;: [ # Routines in the requested dataset. Unless read_mask is set in the request,
Dan O'Mearadd494642020-05-01 07:42:23 -0700494 # only the following fields are populated:
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700495 # etag, project_id, dataset_id, routine_id, routine_type, creation_time,
Dan O'Mearadd494642020-05-01 07:42:23 -0700496 # last_modified_time, and language.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700497 { # A user-defined function or a stored procedure.
Bu Sun Kim65020912020-05-20 12:08:20 -0700498 &quot;importedLibraries&quot;: [ # Optional. If language = &quot;JAVASCRIPT&quot;, this field stores the path of the
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700499 # imported JAVASCRIPT libraries.
Bu Sun Kim65020912020-05-20 12:08:20 -0700500 &quot;A String&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700501 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700502 &quot;lastModifiedTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was last modified, in milliseconds
503 # since the epoch.
504 &quot;returnType&quot;: { # The type of a variable, e.g., a function argument. # Optional if language = &quot;SQL&quot;; required otherwise.
Dan O'Mearadd494642020-05-01 07:42:23 -0700505 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700506 # If absent, the return type is inferred from definition_body at query time
507 # in each query that references this routine. If present, then the evaluated
508 # result will be cast to the specified returned type at query time.
509 #
Dan O'Mearadd494642020-05-01 07:42:23 -0700510 # For example, for the functions created with the following statements:
511 #
512 # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);`
513 #
514 # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));`
515 #
516 # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));`
517 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700518 # The return_type is `{type_kind: &quot;FLOAT64&quot;}` for `Add` and `Decrement`, and
Dan O'Mearadd494642020-05-01 07:42:23 -0700519 # is absent for `Increment` (inferred as FLOAT64 at query time).
520 #
521 # Suppose the function `Add` is replaced by
522 # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);`
523 #
524 # Then the inferred return type of `Increment` is automatically changed to
525 # INT64 at query time, while the return type of `Decrement` remains FLOAT64.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700526 # Examples:
Bu Sun Kim65020912020-05-20 12:08:20 -0700527 # INT64: {type_kind=&quot;INT64&quot;}
528 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
Dan O'Mearadd494642020-05-01 07:42:23 -0700529 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
Bu Sun Kim65020912020-05-20 12:08:20 -0700530 # {type_kind=&quot;STRUCT&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700531 # struct_type={fields=[
Bu Sun Kim65020912020-05-20 12:08:20 -0700532 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
533 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700534 # ]}}
Bu Sun Kim65020912020-05-20 12:08:20 -0700535 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
536 &quot;fields&quot;: [
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700537 # Object with schema name: StandardSqlField
538 ],
539 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700540 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
541 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
542 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700543 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700544 &quot;language&quot;: &quot;A String&quot;, # Optional. Defaults to &quot;SQL&quot;.
545 &quot;description&quot;: &quot;A String&quot;, # Optional. [Experimental] The description of the routine if defined.
546 &quot;etag&quot;: &quot;A String&quot;, # Output only. A hash of this resource.
547 &quot;definitionBody&quot;: &quot;A String&quot;, # Required. The body of the routine.
Dan O'Mearadd494642020-05-01 07:42:23 -0700548 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700549 # For functions, this is the expression in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700550 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700551 # If language=SQL, it is the substring inside (but excluding) the
552 # parentheses. For example, for the function created with the following
Dan O'Mearadd494642020-05-01 07:42:23 -0700553 # statement:
554 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700555 # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, &quot;\n&quot;, y))`
Dan O'Mearadd494642020-05-01 07:42:23 -0700556 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700557 # The definition_body is `concat(x, &quot;\n&quot;, y)` (\n is not replaced with
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700558 # linebreak).
Dan O'Mearadd494642020-05-01 07:42:23 -0700559 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700560 # If language=JAVASCRIPT, it is the evaluated string in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700561 # For example, for the function created with the following statement:
562 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700563 # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS &#x27;return &quot;\n&quot;;\n&#x27;`
Dan O'Mearadd494642020-05-01 07:42:23 -0700564 #
565 # The definition_body is
566 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700567 # `return &quot;\n&quot;;\n`
Dan O'Mearadd494642020-05-01 07:42:23 -0700568 #
569 # Note that both \n are replaced with linebreaks.
Bu Sun Kim65020912020-05-20 12:08:20 -0700570 &quot;creationTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was created, in milliseconds since
571 # the epoch.
572 &quot;routineType&quot;: &quot;A String&quot;, # Required. The type of routine.
573 &quot;routineReference&quot;: { # Required. Reference describing the ID of this routine.
574 &quot;projectId&quot;: &quot;A String&quot;, # [Required] The ID of the project containing this routine.
575 &quot;datasetId&quot;: &quot;A String&quot;, # [Required] The ID of the dataset containing this routine.
576 &quot;routineId&quot;: &quot;A String&quot;, # [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
577 },
578 &quot;arguments&quot;: [ # Optional.
579 { # Input/output argument of a function or a stored procedure.
580 &quot;name&quot;: &quot;A String&quot;, # Optional. The name of this argument. Can be absent for function return argument.
581 &quot;argumentKind&quot;: &quot;A String&quot;, # Optional. Defaults to FIXED_TYPE.
582 &quot;mode&quot;: &quot;A String&quot;, # Optional. Specifies whether the argument is input or output.
583 # Can be set for procedures only.
584 &quot;dataType&quot;: { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE.
585 # Examples:
586 # INT64: {type_kind=&quot;INT64&quot;}
587 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
588 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
589 # {type_kind=&quot;STRUCT&quot;,
590 # struct_type={fields=[
591 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
592 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
593 # ]}}
594 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
595 &quot;fields&quot;: [
596 # Object with schema name: StandardSqlField
597 ],
598 },
599 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
600 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
601 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
602 },
603 },
604 ],
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700605 },
606 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700607 &quot;nextPageToken&quot;: &quot;A String&quot;, # A token to request the next page of results.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700608 }</pre>
609</div>
610
611<div class="method">
612 <code class="details" id="list_next">list_next(previous_request, previous_response)</code>
613 <pre>Retrieves the next page of results.
614
615Args:
616 previous_request: The request for the previous page. (required)
617 previous_response: The response from the request for the previous page. (required)
618
619Returns:
Bu Sun Kim65020912020-05-20 12:08:20 -0700620 A request object that you can call &#x27;execute()&#x27; on to request the next
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700621 page. Returns None if there are no more items in the collection.
622 </pre>
623</div>
624
625<div class="method">
Dan O'Mearadd494642020-05-01 07:42:23 -0700626 <code class="details" id="update">update(projectId, datasetId, routineId, body=None)</code>
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700627 <pre>Updates information in an existing routine. The update method replaces the
628entire Routine resource.
629
630Args:
Dan O'Mearadd494642020-05-01 07:42:23 -0700631 projectId: string, Required. Project ID of the routine to update (required)
632 datasetId: string, Required. Dataset ID of the routine to update (required)
633 routineId: string, Required. Routine ID of the routine to update (required)
634 body: object, The request body.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700635 The object takes the form of:
636
637{ # A user-defined function or a stored procedure.
Bu Sun Kim65020912020-05-20 12:08:20 -0700638 &quot;importedLibraries&quot;: [ # Optional. If language = &quot;JAVASCRIPT&quot;, this field stores the path of the
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700639 # imported JAVASCRIPT libraries.
Bu Sun Kim65020912020-05-20 12:08:20 -0700640 &quot;A String&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700641 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700642 &quot;lastModifiedTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was last modified, in milliseconds
643 # since the epoch.
644 &quot;returnType&quot;: { # The type of a variable, e.g., a function argument. # Optional if language = &quot;SQL&quot;; required otherwise.
Dan O'Mearadd494642020-05-01 07:42:23 -0700645 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700646 # If absent, the return type is inferred from definition_body at query time
647 # in each query that references this routine. If present, then the evaluated
648 # result will be cast to the specified returned type at query time.
649 #
Dan O'Mearadd494642020-05-01 07:42:23 -0700650 # For example, for the functions created with the following statements:
651 #
652 # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);`
653 #
654 # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));`
655 #
656 # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));`
657 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700658 # The return_type is `{type_kind: &quot;FLOAT64&quot;}` for `Add` and `Decrement`, and
Dan O'Mearadd494642020-05-01 07:42:23 -0700659 # is absent for `Increment` (inferred as FLOAT64 at query time).
660 #
661 # Suppose the function `Add` is replaced by
662 # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);`
663 #
664 # Then the inferred return type of `Increment` is automatically changed to
665 # INT64 at query time, while the return type of `Decrement` remains FLOAT64.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700666 # Examples:
Bu Sun Kim65020912020-05-20 12:08:20 -0700667 # INT64: {type_kind=&quot;INT64&quot;}
668 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
Dan O'Mearadd494642020-05-01 07:42:23 -0700669 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
Bu Sun Kim65020912020-05-20 12:08:20 -0700670 # {type_kind=&quot;STRUCT&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700671 # struct_type={fields=[
Bu Sun Kim65020912020-05-20 12:08:20 -0700672 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
673 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700674 # ]}}
Bu Sun Kim65020912020-05-20 12:08:20 -0700675 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
676 &quot;fields&quot;: [
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700677 # Object with schema name: StandardSqlField
678 ],
679 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700680 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
681 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
682 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700683 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700684 &quot;language&quot;: &quot;A String&quot;, # Optional. Defaults to &quot;SQL&quot;.
685 &quot;description&quot;: &quot;A String&quot;, # Optional. [Experimental] The description of the routine if defined.
686 &quot;etag&quot;: &quot;A String&quot;, # Output only. A hash of this resource.
687 &quot;definitionBody&quot;: &quot;A String&quot;, # Required. The body of the routine.
Dan O'Mearadd494642020-05-01 07:42:23 -0700688 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700689 # For functions, this is the expression in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700690 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700691 # If language=SQL, it is the substring inside (but excluding) the
692 # parentheses. For example, for the function created with the following
Dan O'Mearadd494642020-05-01 07:42:23 -0700693 # statement:
694 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700695 # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, &quot;\n&quot;, y))`
Dan O'Mearadd494642020-05-01 07:42:23 -0700696 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700697 # The definition_body is `concat(x, &quot;\n&quot;, y)` (\n is not replaced with
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700698 # linebreak).
Dan O'Mearadd494642020-05-01 07:42:23 -0700699 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700700 # If language=JAVASCRIPT, it is the evaluated string in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700701 # For example, for the function created with the following statement:
702 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700703 # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS &#x27;return &quot;\n&quot;;\n&#x27;`
Dan O'Mearadd494642020-05-01 07:42:23 -0700704 #
705 # The definition_body is
706 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700707 # `return &quot;\n&quot;;\n`
Dan O'Mearadd494642020-05-01 07:42:23 -0700708 #
709 # Note that both \n are replaced with linebreaks.
Bu Sun Kim65020912020-05-20 12:08:20 -0700710 &quot;creationTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was created, in milliseconds since
711 # the epoch.
712 &quot;routineType&quot;: &quot;A String&quot;, # Required. The type of routine.
713 &quot;routineReference&quot;: { # Required. Reference describing the ID of this routine.
714 &quot;projectId&quot;: &quot;A String&quot;, # [Required] The ID of the project containing this routine.
715 &quot;datasetId&quot;: &quot;A String&quot;, # [Required] The ID of the dataset containing this routine.
716 &quot;routineId&quot;: &quot;A String&quot;, # [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
717 },
718 &quot;arguments&quot;: [ # Optional.
719 { # Input/output argument of a function or a stored procedure.
720 &quot;name&quot;: &quot;A String&quot;, # Optional. The name of this argument. Can be absent for function return argument.
721 &quot;argumentKind&quot;: &quot;A String&quot;, # Optional. Defaults to FIXED_TYPE.
722 &quot;mode&quot;: &quot;A String&quot;, # Optional. Specifies whether the argument is input or output.
723 # Can be set for procedures only.
724 &quot;dataType&quot;: { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE.
725 # Examples:
726 # INT64: {type_kind=&quot;INT64&quot;}
727 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
728 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
729 # {type_kind=&quot;STRUCT&quot;,
730 # struct_type={fields=[
731 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
732 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
733 # ]}}
734 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
735 &quot;fields&quot;: [
736 # Object with schema name: StandardSqlField
737 ],
738 },
739 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
740 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
741 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
742 },
743 },
744 ],
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700745 }
746
747
748Returns:
749 An object of the form:
750
751 { # A user-defined function or a stored procedure.
Bu Sun Kim65020912020-05-20 12:08:20 -0700752 &quot;importedLibraries&quot;: [ # Optional. If language = &quot;JAVASCRIPT&quot;, this field stores the path of the
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700753 # imported JAVASCRIPT libraries.
Bu Sun Kim65020912020-05-20 12:08:20 -0700754 &quot;A String&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700755 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700756 &quot;lastModifiedTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was last modified, in milliseconds
757 # since the epoch.
758 &quot;returnType&quot;: { # The type of a variable, e.g., a function argument. # Optional if language = &quot;SQL&quot;; required otherwise.
Dan O'Mearadd494642020-05-01 07:42:23 -0700759 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700760 # If absent, the return type is inferred from definition_body at query time
761 # in each query that references this routine. If present, then the evaluated
762 # result will be cast to the specified returned type at query time.
763 #
Dan O'Mearadd494642020-05-01 07:42:23 -0700764 # For example, for the functions created with the following statements:
765 #
766 # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);`
767 #
768 # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));`
769 #
770 # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));`
771 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700772 # The return_type is `{type_kind: &quot;FLOAT64&quot;}` for `Add` and `Decrement`, and
Dan O'Mearadd494642020-05-01 07:42:23 -0700773 # is absent for `Increment` (inferred as FLOAT64 at query time).
774 #
775 # Suppose the function `Add` is replaced by
776 # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);`
777 #
778 # Then the inferred return type of `Increment` is automatically changed to
779 # INT64 at query time, while the return type of `Decrement` remains FLOAT64.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700780 # Examples:
Bu Sun Kim65020912020-05-20 12:08:20 -0700781 # INT64: {type_kind=&quot;INT64&quot;}
782 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
Dan O'Mearadd494642020-05-01 07:42:23 -0700783 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
Bu Sun Kim65020912020-05-20 12:08:20 -0700784 # {type_kind=&quot;STRUCT&quot;,
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700785 # struct_type={fields=[
Bu Sun Kim65020912020-05-20 12:08:20 -0700786 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
787 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700788 # ]}}
Bu Sun Kim65020912020-05-20 12:08:20 -0700789 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
790 &quot;fields&quot;: [
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700791 # Object with schema name: StandardSqlField
792 ],
793 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700794 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
795 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
796 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700797 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700798 &quot;language&quot;: &quot;A String&quot;, # Optional. Defaults to &quot;SQL&quot;.
799 &quot;description&quot;: &quot;A String&quot;, # Optional. [Experimental] The description of the routine if defined.
800 &quot;etag&quot;: &quot;A String&quot;, # Output only. A hash of this resource.
801 &quot;definitionBody&quot;: &quot;A String&quot;, # Required. The body of the routine.
Dan O'Mearadd494642020-05-01 07:42:23 -0700802 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700803 # For functions, this is the expression in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700804 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700805 # If language=SQL, it is the substring inside (but excluding) the
806 # parentheses. For example, for the function created with the following
Dan O'Mearadd494642020-05-01 07:42:23 -0700807 # statement:
808 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700809 # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, &quot;\n&quot;, y))`
Dan O'Mearadd494642020-05-01 07:42:23 -0700810 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700811 # The definition_body is `concat(x, &quot;\n&quot;, y)` (\n is not replaced with
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700812 # linebreak).
Dan O'Mearadd494642020-05-01 07:42:23 -0700813 #
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700814 # If language=JAVASCRIPT, it is the evaluated string in the AS clause.
Dan O'Mearadd494642020-05-01 07:42:23 -0700815 # For example, for the function created with the following statement:
816 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700817 # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS &#x27;return &quot;\n&quot;;\n&#x27;`
Dan O'Mearadd494642020-05-01 07:42:23 -0700818 #
819 # The definition_body is
820 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700821 # `return &quot;\n&quot;;\n`
Dan O'Mearadd494642020-05-01 07:42:23 -0700822 #
823 # Note that both \n are replaced with linebreaks.
Bu Sun Kim65020912020-05-20 12:08:20 -0700824 &quot;creationTime&quot;: &quot;A String&quot;, # Output only. The time when this routine was created, in milliseconds since
825 # the epoch.
826 &quot;routineType&quot;: &quot;A String&quot;, # Required. The type of routine.
827 &quot;routineReference&quot;: { # Required. Reference describing the ID of this routine.
828 &quot;projectId&quot;: &quot;A String&quot;, # [Required] The ID of the project containing this routine.
829 &quot;datasetId&quot;: &quot;A String&quot;, # [Required] The ID of the dataset containing this routine.
830 &quot;routineId&quot;: &quot;A String&quot;, # [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
831 },
832 &quot;arguments&quot;: [ # Optional.
833 { # Input/output argument of a function or a stored procedure.
834 &quot;name&quot;: &quot;A String&quot;, # Optional. The name of this argument. Can be absent for function return argument.
835 &quot;argumentKind&quot;: &quot;A String&quot;, # Optional. Defaults to FIXED_TYPE.
836 &quot;mode&quot;: &quot;A String&quot;, # Optional. Specifies whether the argument is input or output.
837 # Can be set for procedures only.
838 &quot;dataType&quot;: { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE.
839 # Examples:
840 # INT64: {type_kind=&quot;INT64&quot;}
841 # ARRAY&lt;STRING&gt;: {type_kind=&quot;ARRAY&quot;, array_element_type=&quot;STRING&quot;}
842 # STRUCT&lt;x STRING, y ARRAY&lt;DATE&gt;&gt;:
843 # {type_kind=&quot;STRUCT&quot;,
844 # struct_type={fields=[
845 # {name=&quot;x&quot;, type={type_kind=&quot;STRING&quot;}},
846 # {name=&quot;y&quot;, type={type_kind=&quot;ARRAY&quot;, array_element_type=&quot;DATE&quot;}}
847 # ]}}
848 &quot;structType&quot;: { # The fields of this struct, in order, if type_kind = &quot;STRUCT&quot;.
849 &quot;fields&quot;: [
850 # Object with schema name: StandardSqlField
851 ],
852 },
853 &quot;arrayElementType&quot;: # Object with schema name: StandardSqlDataType # The type of the array&#x27;s elements, if type_kind = &quot;ARRAY&quot;.
854 &quot;typeKind&quot;: &quot;A String&quot;, # Required. The top level type of this field.
855 # Can be any standard SQL data type (e.g., &quot;INT64&quot;, &quot;DATE&quot;, &quot;ARRAY&quot;).
856 },
857 },
858 ],
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700859 }</pre>
860</div>
861
862</body></html>