Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 1 | <html><body> |
| 2 | <style> |
| 3 | |
| 4 | body, 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 | |
| 15 | body { |
| 16 | font-size: 13px; |
| 17 | padding: 1em; |
| 18 | } |
| 19 | |
| 20 | h1 { |
| 21 | font-size: 26px; |
| 22 | margin-bottom: 1em; |
| 23 | } |
| 24 | |
| 25 | h2 { |
| 26 | font-size: 24px; |
| 27 | margin-bottom: 1em; |
| 28 | } |
| 29 | |
| 30 | h3 { |
| 31 | font-size: 20px; |
| 32 | margin-bottom: 1em; |
| 33 | margin-top: 1em; |
| 34 | } |
| 35 | |
| 36 | pre, code { |
| 37 | line-height: 1.5; |
| 38 | font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; |
| 39 | } |
| 40 | |
| 41 | pre { |
| 42 | margin-top: 0.5em; |
| 43 | } |
| 44 | |
| 45 | h1, h2, h3, p { |
| 46 | font-family: Arial, sans serif; |
| 47 | } |
| 48 | |
| 49 | h1, 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'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 81 | <code><a href="#get">get(projectId, datasetId, routineId, readMask=None)</a></code></p> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 82 | <p class="firstline">Gets the specified routine resource by routine ID.</p> |
| 83 | <p class="toc_element"> |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 84 | <code><a href="#insert">insert(projectId, datasetId, body=None)</a></code></p> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 85 | <p class="firstline">Creates a new routine in the dataset.</p> |
| 86 | <p class="toc_element"> |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 87 | <code><a href="#list">list(projectId, datasetId, filter=None, pageToken=None, maxResults=None, readMask=None)</a></code></p> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 88 | <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'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 93 | <code><a href="#update">update(projectId, datasetId, routineId, body=None)</a></code></p> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 94 | <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 | |
| 100 | Args: |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 101 | 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 Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 104 | </pre> |
| 105 | </div> |
| 106 | |
| 107 | <div class="method"> |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 108 | <code class="details" id="get">get(projectId, datasetId, routineId, readMask=None)</code> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 109 | <pre>Gets the specified routine resource by routine ID. |
| 110 | |
| 111 | Args: |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 112 | 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 Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 116 | response. If unset, all Routine fields are returned. |
| 117 | |
| 118 | Returns: |
| 119 | An object of the form: |
| 120 | |
| 121 | { # A user-defined function or a stored procedure. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 122 | "routineType": "A String", # Required. The type of routine. |
| 123 | "description": "A String", # Optional. [Experimental] The description of the routine if defined. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 124 | "language": "A String", # Optional. Defaults to "SQL". |
| 125 | "creationTime": "A String", # Output only. The time when this routine was created, in milliseconds since |
| 126 | # the epoch. |
| 127 | "importedLibraries": [ # Optional. If language = "JAVASCRIPT", this field stores the path of the |
| 128 | # imported JAVASCRIPT libraries. |
| 129 | "A String", |
| 130 | ], |
| 131 | "routineReference": { # Required. Reference describing the ID of this routine. |
| 132 | "projectId": "A String", # [Required] The ID of the project containing this routine. |
| 133 | "routineId": "A String", # [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. |
| 134 | "datasetId": "A String", # [Required] The ID of the dataset containing this routine. |
| 135 | }, |
| 136 | "etag": "A String", # Output only. A hash of this resource. |
| 137 | "arguments": [ # Optional. |
| 138 | { # Input/output argument of a function or a stored procedure. |
| 139 | "dataType": { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE. |
| 140 | # Examples: |
| 141 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 142 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 143 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 144 | # {type_kind="STRUCT", |
| 145 | # struct_type={fields=[ |
| 146 | # {name="x", type={type_kind="STRING"}}, |
| 147 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 148 | # ]}} |
| 149 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 150 | "fields": [ |
| 151 | # Object with schema name: StandardSqlField |
| 152 | ], |
| 153 | }, |
| 154 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 155 | "typeKind": "A String", # Required. The top level type of this field. |
| 156 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 157 | }, |
| 158 | "argumentKind": "A String", # Optional. Defaults to FIXED_TYPE. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 159 | "name": "A String", # Optional. The name of this argument. Can be absent for function return argument. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 160 | "mode": "A String", # Optional. Specifies whether the argument is input or output. |
| 161 | # Can be set for procedures only. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 162 | }, |
| 163 | ], |
| 164 | "returnType": { # The type of a variable, e.g., a function argument. # Optional if language = "SQL"; required otherwise. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 165 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 166 | # If absent, the return type is inferred from definition_body at query time |
| 167 | # in each query that references this routine. If present, then the evaluated |
| 168 | # result will be cast to the specified returned type at query time. |
| 169 | # |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 170 | # For example, for the functions created with the following statements: |
| 171 | # |
| 172 | # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` |
| 173 | # |
| 174 | # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` |
| 175 | # |
| 176 | # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` |
| 177 | # |
| 178 | # The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and |
| 179 | # is absent for `Increment` (inferred as FLOAT64 at query time). |
| 180 | # |
| 181 | # Suppose the function `Add` is replaced by |
| 182 | # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` |
| 183 | # |
| 184 | # Then the inferred return type of `Increment` is automatically changed to |
| 185 | # INT64 at query time, while the return type of `Decrement` remains FLOAT64. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 186 | # Examples: |
| 187 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 188 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 189 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 190 | # {type_kind="STRUCT", |
| 191 | # struct_type={fields=[ |
| 192 | # {name="x", type={type_kind="STRING"}}, |
| 193 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 194 | # ]}} |
| 195 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 196 | "fields": [ |
| 197 | # Object with schema name: StandardSqlField |
| 198 | ], |
| 199 | }, |
| 200 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 201 | "typeKind": "A String", # Required. The top level type of this field. |
| 202 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 203 | }, |
| 204 | "lastModifiedTime": "A String", # Output only. The time when this routine was last modified, in milliseconds |
| 205 | # since the epoch. |
| 206 | "definitionBody": "A String", # Required. The body of the routine. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 207 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 208 | # For functions, this is the expression in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 209 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 210 | # If language=SQL, it is the substring inside (but excluding) the |
| 211 | # parentheses. For example, for the function created with the following |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 212 | # statement: |
| 213 | # |
| 214 | # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` |
| 215 | # |
| 216 | # The definition_body is `concat(x, "\n", y)` (\n is not replaced with |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 217 | # linebreak). |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 218 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 219 | # If language=JAVASCRIPT, it is the evaluated string in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 220 | # For example, for the function created with the following statement: |
| 221 | # |
| 222 | # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` |
| 223 | # |
| 224 | # The definition_body is |
| 225 | # |
| 226 | # `return "\n";\n` |
| 227 | # |
| 228 | # Note that both \n are replaced with linebreaks. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 229 | }</pre> |
| 230 | </div> |
| 231 | |
| 232 | <div class="method"> |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 233 | <code class="details" id="insert">insert(projectId, datasetId, body=None)</code> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 234 | <pre>Creates a new routine in the dataset. |
| 235 | |
| 236 | Args: |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 237 | 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 Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 240 | The object takes the form of: |
| 241 | |
| 242 | { # A user-defined function or a stored procedure. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 243 | "routineType": "A String", # Required. The type of routine. |
| 244 | "description": "A String", # Optional. [Experimental] The description of the routine if defined. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 245 | "language": "A String", # Optional. Defaults to "SQL". |
| 246 | "creationTime": "A String", # Output only. The time when this routine was created, in milliseconds since |
| 247 | # the epoch. |
| 248 | "importedLibraries": [ # Optional. If language = "JAVASCRIPT", this field stores the path of the |
| 249 | # imported JAVASCRIPT libraries. |
| 250 | "A String", |
| 251 | ], |
| 252 | "routineReference": { # Required. Reference describing the ID of this routine. |
| 253 | "projectId": "A String", # [Required] The ID of the project containing this routine. |
| 254 | "routineId": "A String", # [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. |
| 255 | "datasetId": "A String", # [Required] The ID of the dataset containing this routine. |
| 256 | }, |
| 257 | "etag": "A String", # Output only. A hash of this resource. |
| 258 | "arguments": [ # Optional. |
| 259 | { # Input/output argument of a function or a stored procedure. |
| 260 | "dataType": { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE. |
| 261 | # Examples: |
| 262 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 263 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 264 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 265 | # {type_kind="STRUCT", |
| 266 | # struct_type={fields=[ |
| 267 | # {name="x", type={type_kind="STRING"}}, |
| 268 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 269 | # ]}} |
| 270 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 271 | "fields": [ |
| 272 | # Object with schema name: StandardSqlField |
| 273 | ], |
| 274 | }, |
| 275 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 276 | "typeKind": "A String", # Required. The top level type of this field. |
| 277 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 278 | }, |
| 279 | "argumentKind": "A String", # Optional. Defaults to FIXED_TYPE. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 280 | "name": "A String", # Optional. The name of this argument. Can be absent for function return argument. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 281 | "mode": "A String", # Optional. Specifies whether the argument is input or output. |
| 282 | # Can be set for procedures only. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 283 | }, |
| 284 | ], |
| 285 | "returnType": { # The type of a variable, e.g., a function argument. # Optional if language = "SQL"; required otherwise. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 286 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 287 | # If absent, the return type is inferred from definition_body at query time |
| 288 | # in each query that references this routine. If present, then the evaluated |
| 289 | # result will be cast to the specified returned type at query time. |
| 290 | # |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 291 | # For example, for the functions created with the following statements: |
| 292 | # |
| 293 | # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` |
| 294 | # |
| 295 | # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` |
| 296 | # |
| 297 | # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` |
| 298 | # |
| 299 | # The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and |
| 300 | # is absent for `Increment` (inferred as FLOAT64 at query time). |
| 301 | # |
| 302 | # Suppose the function `Add` is replaced by |
| 303 | # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` |
| 304 | # |
| 305 | # Then the inferred return type of `Increment` is automatically changed to |
| 306 | # INT64 at query time, while the return type of `Decrement` remains FLOAT64. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 307 | # Examples: |
| 308 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 309 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 310 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 311 | # {type_kind="STRUCT", |
| 312 | # struct_type={fields=[ |
| 313 | # {name="x", type={type_kind="STRING"}}, |
| 314 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 315 | # ]}} |
| 316 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 317 | "fields": [ |
| 318 | # Object with schema name: StandardSqlField |
| 319 | ], |
| 320 | }, |
| 321 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 322 | "typeKind": "A String", # Required. The top level type of this field. |
| 323 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 324 | }, |
| 325 | "lastModifiedTime": "A String", # Output only. The time when this routine was last modified, in milliseconds |
| 326 | # since the epoch. |
| 327 | "definitionBody": "A String", # Required. The body of the routine. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 328 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 329 | # For functions, this is the expression in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 330 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 331 | # If language=SQL, it is the substring inside (but excluding) the |
| 332 | # parentheses. For example, for the function created with the following |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 333 | # statement: |
| 334 | # |
| 335 | # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` |
| 336 | # |
| 337 | # The definition_body is `concat(x, "\n", y)` (\n is not replaced with |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 338 | # linebreak). |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 339 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 340 | # If language=JAVASCRIPT, it is the evaluated string in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 341 | # For example, for the function created with the following statement: |
| 342 | # |
| 343 | # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` |
| 344 | # |
| 345 | # The definition_body is |
| 346 | # |
| 347 | # `return "\n";\n` |
| 348 | # |
| 349 | # Note that both \n are replaced with linebreaks. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | |
| 353 | Returns: |
| 354 | An object of the form: |
| 355 | |
| 356 | { # A user-defined function or a stored procedure. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 357 | "routineType": "A String", # Required. The type of routine. |
| 358 | "description": "A String", # Optional. [Experimental] The description of the routine if defined. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 359 | "language": "A String", # Optional. Defaults to "SQL". |
| 360 | "creationTime": "A String", # Output only. The time when this routine was created, in milliseconds since |
| 361 | # the epoch. |
| 362 | "importedLibraries": [ # Optional. If language = "JAVASCRIPT", this field stores the path of the |
| 363 | # imported JAVASCRIPT libraries. |
| 364 | "A String", |
| 365 | ], |
| 366 | "routineReference": { # Required. Reference describing the ID of this routine. |
| 367 | "projectId": "A String", # [Required] The ID of the project containing this routine. |
| 368 | "routineId": "A String", # [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. |
| 369 | "datasetId": "A String", # [Required] The ID of the dataset containing this routine. |
| 370 | }, |
| 371 | "etag": "A String", # Output only. A hash of this resource. |
| 372 | "arguments": [ # Optional. |
| 373 | { # Input/output argument of a function or a stored procedure. |
| 374 | "dataType": { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE. |
| 375 | # Examples: |
| 376 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 377 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 378 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 379 | # {type_kind="STRUCT", |
| 380 | # struct_type={fields=[ |
| 381 | # {name="x", type={type_kind="STRING"}}, |
| 382 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 383 | # ]}} |
| 384 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 385 | "fields": [ |
| 386 | # Object with schema name: StandardSqlField |
| 387 | ], |
| 388 | }, |
| 389 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 390 | "typeKind": "A String", # Required. The top level type of this field. |
| 391 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 392 | }, |
| 393 | "argumentKind": "A String", # Optional. Defaults to FIXED_TYPE. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 394 | "name": "A String", # Optional. The name of this argument. Can be absent for function return argument. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 395 | "mode": "A String", # Optional. Specifies whether the argument is input or output. |
| 396 | # Can be set for procedures only. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 397 | }, |
| 398 | ], |
| 399 | "returnType": { # The type of a variable, e.g., a function argument. # Optional if language = "SQL"; required otherwise. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 400 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 401 | # If absent, the return type is inferred from definition_body at query time |
| 402 | # in each query that references this routine. If present, then the evaluated |
| 403 | # result will be cast to the specified returned type at query time. |
| 404 | # |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 405 | # For example, for the functions created with the following statements: |
| 406 | # |
| 407 | # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` |
| 408 | # |
| 409 | # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` |
| 410 | # |
| 411 | # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` |
| 412 | # |
| 413 | # The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and |
| 414 | # is absent for `Increment` (inferred as FLOAT64 at query time). |
| 415 | # |
| 416 | # Suppose the function `Add` is replaced by |
| 417 | # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` |
| 418 | # |
| 419 | # Then the inferred return type of `Increment` is automatically changed to |
| 420 | # INT64 at query time, while the return type of `Decrement` remains FLOAT64. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 421 | # Examples: |
| 422 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 423 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 424 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 425 | # {type_kind="STRUCT", |
| 426 | # struct_type={fields=[ |
| 427 | # {name="x", type={type_kind="STRING"}}, |
| 428 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 429 | # ]}} |
| 430 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 431 | "fields": [ |
| 432 | # Object with schema name: StandardSqlField |
| 433 | ], |
| 434 | }, |
| 435 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 436 | "typeKind": "A String", # Required. The top level type of this field. |
| 437 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 438 | }, |
| 439 | "lastModifiedTime": "A String", # Output only. The time when this routine was last modified, in milliseconds |
| 440 | # since the epoch. |
| 441 | "definitionBody": "A String", # Required. The body of the routine. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 442 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 443 | # For functions, this is the expression in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 444 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 445 | # If language=SQL, it is the substring inside (but excluding) the |
| 446 | # parentheses. For example, for the function created with the following |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 447 | # statement: |
| 448 | # |
| 449 | # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` |
| 450 | # |
| 451 | # The definition_body is `concat(x, "\n", y)` (\n is not replaced with |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 452 | # linebreak). |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 453 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 454 | # If language=JAVASCRIPT, it is the evaluated string in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 455 | # For example, for the function created with the following statement: |
| 456 | # |
| 457 | # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` |
| 458 | # |
| 459 | # The definition_body is |
| 460 | # |
| 461 | # `return "\n";\n` |
| 462 | # |
| 463 | # Note that both \n are replaced with linebreaks. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 464 | }</pre> |
| 465 | </div> |
| 466 | |
| 467 | <div class="method"> |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 468 | <code class="details" id="list">list(projectId, datasetId, filter=None, pageToken=None, maxResults=None, readMask=None)</code> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 469 | <pre>Lists all routines in the specified dataset. Requires the READER dataset |
| 470 | role. |
| 471 | |
| 472 | Args: |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 473 | projectId: string, Required. Project ID of the routines to list (required) |
| 474 | datasetId: string, Required. Dataset ID of the routines to list (required) |
| 475 | filter: string, If set, then only the Routines matching this filter are returned. |
| 476 | The current supported form is either "routine_type:<RoutineType>" or |
| 477 | "routineType:<RoutineType>", where <RoutineType> is a RoutineType enum. |
| 478 | Example: "routineType:SCALAR_FUNCTION". |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 479 | pageToken: string, Page token, returned by a previous call, to request the next page of |
| 480 | results |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 481 | maxResults: integer, The maximum number of results to return in a single response page. |
| 482 | Leverage the page tokens to iterate through the entire collection. |
| 483 | readMask: string, If set, then only the Routine fields in the field mask, as well as |
| 484 | project_id, dataset_id and routine_id, are returned in the response. |
| 485 | If unset, then the following Routine fields are returned: |
| 486 | etag, project_id, dataset_id, routine_id, routine_type, creation_time, |
| 487 | last_modified_time, and language. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 488 | |
| 489 | Returns: |
| 490 | An object of the form: |
| 491 | |
| 492 | { |
| 493 | "nextPageToken": "A String", # A token to request the next page of results. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 494 | "routines": [ # Routines in the requested dataset. Unless read_mask is set in the request, |
| 495 | # only the following fields are populated: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 496 | # etag, project_id, dataset_id, routine_id, routine_type, creation_time, |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 497 | # last_modified_time, and language. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 498 | { # A user-defined function or a stored procedure. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 499 | "routineType": "A String", # Required. The type of routine. |
| 500 | "description": "A String", # Optional. [Experimental] The description of the routine if defined. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 501 | "language": "A String", # Optional. Defaults to "SQL". |
| 502 | "creationTime": "A String", # Output only. The time when this routine was created, in milliseconds since |
| 503 | # the epoch. |
| 504 | "importedLibraries": [ # Optional. If language = "JAVASCRIPT", this field stores the path of the |
| 505 | # imported JAVASCRIPT libraries. |
| 506 | "A String", |
| 507 | ], |
| 508 | "routineReference": { # Required. Reference describing the ID of this routine. |
| 509 | "projectId": "A String", # [Required] The ID of the project containing this routine. |
| 510 | "routineId": "A String", # [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. |
| 511 | "datasetId": "A String", # [Required] The ID of the dataset containing this routine. |
| 512 | }, |
| 513 | "etag": "A String", # Output only. A hash of this resource. |
| 514 | "arguments": [ # Optional. |
| 515 | { # Input/output argument of a function or a stored procedure. |
| 516 | "dataType": { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE. |
| 517 | # Examples: |
| 518 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 519 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 520 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 521 | # {type_kind="STRUCT", |
| 522 | # struct_type={fields=[ |
| 523 | # {name="x", type={type_kind="STRING"}}, |
| 524 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 525 | # ]}} |
| 526 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 527 | "fields": [ |
| 528 | # Object with schema name: StandardSqlField |
| 529 | ], |
| 530 | }, |
| 531 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 532 | "typeKind": "A String", # Required. The top level type of this field. |
| 533 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 534 | }, |
| 535 | "argumentKind": "A String", # Optional. Defaults to FIXED_TYPE. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 536 | "name": "A String", # Optional. The name of this argument. Can be absent for function return argument. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 537 | "mode": "A String", # Optional. Specifies whether the argument is input or output. |
| 538 | # Can be set for procedures only. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 539 | }, |
| 540 | ], |
| 541 | "returnType": { # The type of a variable, e.g., a function argument. # Optional if language = "SQL"; required otherwise. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 542 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 543 | # If absent, the return type is inferred from definition_body at query time |
| 544 | # in each query that references this routine. If present, then the evaluated |
| 545 | # result will be cast to the specified returned type at query time. |
| 546 | # |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 547 | # For example, for the functions created with the following statements: |
| 548 | # |
| 549 | # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` |
| 550 | # |
| 551 | # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` |
| 552 | # |
| 553 | # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` |
| 554 | # |
| 555 | # The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and |
| 556 | # is absent for `Increment` (inferred as FLOAT64 at query time). |
| 557 | # |
| 558 | # Suppose the function `Add` is replaced by |
| 559 | # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` |
| 560 | # |
| 561 | # Then the inferred return type of `Increment` is automatically changed to |
| 562 | # INT64 at query time, while the return type of `Decrement` remains FLOAT64. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 563 | # Examples: |
| 564 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 565 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 566 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 567 | # {type_kind="STRUCT", |
| 568 | # struct_type={fields=[ |
| 569 | # {name="x", type={type_kind="STRING"}}, |
| 570 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 571 | # ]}} |
| 572 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 573 | "fields": [ |
| 574 | # Object with schema name: StandardSqlField |
| 575 | ], |
| 576 | }, |
| 577 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 578 | "typeKind": "A String", # Required. The top level type of this field. |
| 579 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 580 | }, |
| 581 | "lastModifiedTime": "A String", # Output only. The time when this routine was last modified, in milliseconds |
| 582 | # since the epoch. |
| 583 | "definitionBody": "A String", # Required. The body of the routine. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 584 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 585 | # For functions, this is the expression in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 586 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 587 | # If language=SQL, it is the substring inside (but excluding) the |
| 588 | # parentheses. For example, for the function created with the following |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 589 | # statement: |
| 590 | # |
| 591 | # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` |
| 592 | # |
| 593 | # The definition_body is `concat(x, "\n", y)` (\n is not replaced with |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 594 | # linebreak). |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 595 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 596 | # If language=JAVASCRIPT, it is the evaluated string in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 597 | # For example, for the function created with the following statement: |
| 598 | # |
| 599 | # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` |
| 600 | # |
| 601 | # The definition_body is |
| 602 | # |
| 603 | # `return "\n";\n` |
| 604 | # |
| 605 | # Note that both \n are replaced with linebreaks. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 606 | }, |
| 607 | ], |
| 608 | }</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 | |
| 615 | Args: |
| 616 | previous_request: The request for the previous page. (required) |
| 617 | previous_response: The response from the request for the previous page. (required) |
| 618 | |
| 619 | Returns: |
| 620 | A request object that you can call 'execute()' on to request the next |
| 621 | page. Returns None if there are no more items in the collection. |
| 622 | </pre> |
| 623 | </div> |
| 624 | |
| 625 | <div class="method"> |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 626 | <code class="details" id="update">update(projectId, datasetId, routineId, body=None)</code> |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 627 | <pre>Updates information in an existing routine. The update method replaces the |
| 628 | entire Routine resource. |
| 629 | |
| 630 | Args: |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 631 | 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 Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 635 | The object takes the form of: |
| 636 | |
| 637 | { # A user-defined function or a stored procedure. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 638 | "routineType": "A String", # Required. The type of routine. |
| 639 | "description": "A String", # Optional. [Experimental] The description of the routine if defined. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 640 | "language": "A String", # Optional. Defaults to "SQL". |
| 641 | "creationTime": "A String", # Output only. The time when this routine was created, in milliseconds since |
| 642 | # the epoch. |
| 643 | "importedLibraries": [ # Optional. If language = "JAVASCRIPT", this field stores the path of the |
| 644 | # imported JAVASCRIPT libraries. |
| 645 | "A String", |
| 646 | ], |
| 647 | "routineReference": { # Required. Reference describing the ID of this routine. |
| 648 | "projectId": "A String", # [Required] The ID of the project containing this routine. |
| 649 | "routineId": "A String", # [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. |
| 650 | "datasetId": "A String", # [Required] The ID of the dataset containing this routine. |
| 651 | }, |
| 652 | "etag": "A String", # Output only. A hash of this resource. |
| 653 | "arguments": [ # Optional. |
| 654 | { # Input/output argument of a function or a stored procedure. |
| 655 | "dataType": { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE. |
| 656 | # Examples: |
| 657 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 658 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 659 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 660 | # {type_kind="STRUCT", |
| 661 | # struct_type={fields=[ |
| 662 | # {name="x", type={type_kind="STRING"}}, |
| 663 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 664 | # ]}} |
| 665 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 666 | "fields": [ |
| 667 | # Object with schema name: StandardSqlField |
| 668 | ], |
| 669 | }, |
| 670 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 671 | "typeKind": "A String", # Required. The top level type of this field. |
| 672 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 673 | }, |
| 674 | "argumentKind": "A String", # Optional. Defaults to FIXED_TYPE. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 675 | "name": "A String", # Optional. The name of this argument. Can be absent for function return argument. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 676 | "mode": "A String", # Optional. Specifies whether the argument is input or output. |
| 677 | # Can be set for procedures only. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 678 | }, |
| 679 | ], |
| 680 | "returnType": { # The type of a variable, e.g., a function argument. # Optional if language = "SQL"; required otherwise. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 681 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 682 | # If absent, the return type is inferred from definition_body at query time |
| 683 | # in each query that references this routine. If present, then the evaluated |
| 684 | # result will be cast to the specified returned type at query time. |
| 685 | # |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 686 | # For example, for the functions created with the following statements: |
| 687 | # |
| 688 | # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` |
| 689 | # |
| 690 | # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` |
| 691 | # |
| 692 | # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` |
| 693 | # |
| 694 | # The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and |
| 695 | # is absent for `Increment` (inferred as FLOAT64 at query time). |
| 696 | # |
| 697 | # Suppose the function `Add` is replaced by |
| 698 | # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` |
| 699 | # |
| 700 | # Then the inferred return type of `Increment` is automatically changed to |
| 701 | # INT64 at query time, while the return type of `Decrement` remains FLOAT64. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 702 | # Examples: |
| 703 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 704 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 705 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 706 | # {type_kind="STRUCT", |
| 707 | # struct_type={fields=[ |
| 708 | # {name="x", type={type_kind="STRING"}}, |
| 709 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 710 | # ]}} |
| 711 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 712 | "fields": [ |
| 713 | # Object with schema name: StandardSqlField |
| 714 | ], |
| 715 | }, |
| 716 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 717 | "typeKind": "A String", # Required. The top level type of this field. |
| 718 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 719 | }, |
| 720 | "lastModifiedTime": "A String", # Output only. The time when this routine was last modified, in milliseconds |
| 721 | # since the epoch. |
| 722 | "definitionBody": "A String", # Required. The body of the routine. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 723 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 724 | # For functions, this is the expression in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 725 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 726 | # If language=SQL, it is the substring inside (but excluding) the |
| 727 | # parentheses. For example, for the function created with the following |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 728 | # statement: |
| 729 | # |
| 730 | # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` |
| 731 | # |
| 732 | # The definition_body is `concat(x, "\n", y)` (\n is not replaced with |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 733 | # linebreak). |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 734 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 735 | # If language=JAVASCRIPT, it is the evaluated string in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 736 | # For example, for the function created with the following statement: |
| 737 | # |
| 738 | # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` |
| 739 | # |
| 740 | # The definition_body is |
| 741 | # |
| 742 | # `return "\n";\n` |
| 743 | # |
| 744 | # Note that both \n are replaced with linebreaks. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | |
| 748 | Returns: |
| 749 | An object of the form: |
| 750 | |
| 751 | { # A user-defined function or a stored procedure. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 752 | "routineType": "A String", # Required. The type of routine. |
| 753 | "description": "A String", # Optional. [Experimental] The description of the routine if defined. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 754 | "language": "A String", # Optional. Defaults to "SQL". |
| 755 | "creationTime": "A String", # Output only. The time when this routine was created, in milliseconds since |
| 756 | # the epoch. |
| 757 | "importedLibraries": [ # Optional. If language = "JAVASCRIPT", this field stores the path of the |
| 758 | # imported JAVASCRIPT libraries. |
| 759 | "A String", |
| 760 | ], |
| 761 | "routineReference": { # Required. Reference describing the ID of this routine. |
| 762 | "projectId": "A String", # [Required] The ID of the project containing this routine. |
| 763 | "routineId": "A String", # [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. |
| 764 | "datasetId": "A String", # [Required] The ID of the dataset containing this routine. |
| 765 | }, |
| 766 | "etag": "A String", # Output only. A hash of this resource. |
| 767 | "arguments": [ # Optional. |
| 768 | { # Input/output argument of a function or a stored procedure. |
| 769 | "dataType": { # The type of a variable, e.g., a function argument. # Required unless argument_kind = ANY_TYPE. |
| 770 | # Examples: |
| 771 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 772 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 773 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 774 | # {type_kind="STRUCT", |
| 775 | # struct_type={fields=[ |
| 776 | # {name="x", type={type_kind="STRING"}}, |
| 777 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 778 | # ]}} |
| 779 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 780 | "fields": [ |
| 781 | # Object with schema name: StandardSqlField |
| 782 | ], |
| 783 | }, |
| 784 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 785 | "typeKind": "A String", # Required. The top level type of this field. |
| 786 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 787 | }, |
| 788 | "argumentKind": "A String", # Optional. Defaults to FIXED_TYPE. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 789 | "name": "A String", # Optional. The name of this argument. Can be absent for function return argument. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 790 | "mode": "A String", # Optional. Specifies whether the argument is input or output. |
| 791 | # Can be set for procedures only. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 792 | }, |
| 793 | ], |
| 794 | "returnType": { # The type of a variable, e.g., a function argument. # Optional if language = "SQL"; required otherwise. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 795 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 796 | # If absent, the return type is inferred from definition_body at query time |
| 797 | # in each query that references this routine. If present, then the evaluated |
| 798 | # result will be cast to the specified returned type at query time. |
| 799 | # |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 800 | # For example, for the functions created with the following statements: |
| 801 | # |
| 802 | # * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` |
| 803 | # |
| 804 | # * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` |
| 805 | # |
| 806 | # * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` |
| 807 | # |
| 808 | # The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and |
| 809 | # is absent for `Increment` (inferred as FLOAT64 at query time). |
| 810 | # |
| 811 | # Suppose the function `Add` is replaced by |
| 812 | # `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` |
| 813 | # |
| 814 | # Then the inferred return type of `Increment` is automatically changed to |
| 815 | # INT64 at query time, while the return type of `Decrement` remains FLOAT64. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 816 | # Examples: |
| 817 | # INT64: {type_kind="INT64"} |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 818 | # ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"} |
| 819 | # STRUCT<x STRING, y ARRAY<DATE>>: |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 820 | # {type_kind="STRUCT", |
| 821 | # struct_type={fields=[ |
| 822 | # {name="x", type={type_kind="STRING"}}, |
| 823 | # {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} |
| 824 | # ]}} |
| 825 | "structType": { # The fields of this struct, in order, if type_kind = "STRUCT". |
| 826 | "fields": [ |
| 827 | # Object with schema name: StandardSqlField |
| 828 | ], |
| 829 | }, |
| 830 | "arrayElementType": # Object with schema name: StandardSqlDataType # The type of the array's elements, if type_kind = "ARRAY". |
| 831 | "typeKind": "A String", # Required. The top level type of this field. |
| 832 | # Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). |
| 833 | }, |
| 834 | "lastModifiedTime": "A String", # Output only. The time when this routine was last modified, in milliseconds |
| 835 | # since the epoch. |
| 836 | "definitionBody": "A String", # Required. The body of the routine. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 837 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 838 | # For functions, this is the expression in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 839 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 840 | # If language=SQL, it is the substring inside (but excluding) the |
| 841 | # parentheses. For example, for the function created with the following |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 842 | # statement: |
| 843 | # |
| 844 | # `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` |
| 845 | # |
| 846 | # The definition_body is `concat(x, "\n", y)` (\n is not replaced with |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 847 | # linebreak). |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 848 | # |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 849 | # If language=JAVASCRIPT, it is the evaluated string in the AS clause. |
Dan O'Meara | dd49464 | 2020-05-01 07:42:23 -0700 | [diff] [blame^] | 850 | # For example, for the function created with the following statement: |
| 851 | # |
| 852 | # `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` |
| 853 | # |
| 854 | # The definition_body is |
| 855 | # |
| 856 | # `return "\n";\n` |
| 857 | # |
| 858 | # Note that both \n are replaced with linebreaks. |
Bu Sun Kim | 715bd7f | 2019-06-14 16:50:42 -0700 | [diff] [blame] | 859 | }</pre> |
| 860 | </div> |
| 861 | |
| 862 | </body></html> |