Class: Google::Cloud::Bigquery::Routine::Updater
- Inherits:
-
Google::Cloud::Bigquery::Routine
- Object
- Google::Cloud::Bigquery::Routine
- Google::Cloud::Bigquery::Routine::Updater
- Defined in:
- lib/google/cloud/bigquery/routine.rb
Overview
Yielded to a block to accumulate changes. See Dataset#create_routine and #update.
Lifecycle collapse
-
#arguments=(new_arguments) ⇒ Object
Updates the input/output arguments of the routine.
-
#body=(new_body) ⇒ Object
Updates the body of the routine.
- #delete ⇒ Object
-
#description=(new_description) ⇒ Object
Updates the description of the routine.
-
#imported_libraries=(new_imported_libraries) ⇒ Object
Updates the list of the Google Cloud Storage URIs of imported JavaScript libraries.
-
#language=(new_language) ⇒ Object
Updates the programming language of routine.
- #reload! ⇒ Object (also: #refresh!)
-
#return_type=(new_return_type) ⇒ Object
Updates the return type of the routine.
-
#routine_type=(new_routine_type) ⇒ Object
Updates the type of routine.
- #update ⇒ Object
Methods inherited from Google::Cloud::Bigquery::Routine
#arguments, #body, #created_at, #dataset_id, #description, #etag, #exists?, #imported_libraries, #javascript?, #language, #modified_at, #procedure?, #project_id, #reference?, #resource?, #resource_full?, #resource_partial?, #return_type, #routine_id, #routine_type, #scalar_function?, #sql?
Instance Method Details
#arguments=(new_arguments) ⇒ Object
Updates the input/output arguments of the routine. Optional.
966 967 968 |
# File 'lib/google/cloud/bigquery/routine.rb', line 966 def arguments= new_arguments @gapi.arguments = new_arguments.map(&:to_gapi) end |
#body=(new_body) ⇒ Object
Updates the body of the routine. Required.
For functions (Google::Cloud::Bigquery::Routine#scalar_function?), this is the expression in the AS clause.
When the routine is a SQL function (Google::Cloud::Bigquery::Routine#sql?), it is the substring inside (but excluding) the parentheses. For example, for the function created with the following statement:
CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))
The definition_body is concat(x, "\n", y) (\n is not replaced with linebreak).
When the routine is a JavaScript function (Google::Cloud::Bigquery::Routine#javascript?), it is the evaluated string in the AS clause.
For example, for the function created with the following statement:
CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'
The definition_body is
"return \"\n\";\n"`
Note that both \n are replaced with linebreaks.
1055 1056 1057 |
# File 'lib/google/cloud/bigquery/routine.rb', line 1055 def body= new_body @gapi.definition_body = new_body end |
#delete ⇒ Object
1082 1083 1084 |
# File 'lib/google/cloud/bigquery/routine.rb', line 1082 def delete raise "not implemented in #{self.class}" end |
#description=(new_description) ⇒ Object
Updates the description of the routine. Optional. [Experimental]
1074 1075 1076 |
# File 'lib/google/cloud/bigquery/routine.rb', line 1074 def description= new_description @gapi.description = new_description end |
#imported_libraries=(new_imported_libraries) ⇒ Object
Updates the list of the Google Cloud Storage URIs of imported JavaScript libraries. Optional. Only used if
Google::Cloud::Bigquery::Routine#language is JAVASCRIPT (Google::Cloud::Bigquery::Routine#javascript?).
1026 1027 1028 |
# File 'lib/google/cloud/bigquery/routine.rb', line 1026 def imported_libraries= new_imported_libraries @gapi.imported_libraries = new_imported_libraries end |
#language=(new_language) ⇒ Object
Updates the programming language of routine. Optional. Defaults to "SQL".
SQL- SQL language.JAVASCRIPT- JavaScript language.
946 947 948 |
# File 'lib/google/cloud/bigquery/routine.rb', line 946 def language= new_language @gapi.language = new_language end |
#reload! ⇒ Object Also known as: refresh!
1086 1087 1088 |
# File 'lib/google/cloud/bigquery/routine.rb', line 1086 def reload! raise "not implemented in #{self.class}" end |
#return_type=(new_return_type) ⇒ Object
Updates the return type of the routine. Optional if the routine is a SQL function (Google::Cloud::Bigquery::Routine#sql?); required otherwise.
If absent, the return type is inferred from Google::Cloud::Bigquery::Routine#body at query time in each query that references this routine. If present, then the evaluated result will be cast to the specified returned type at query time.
For example, for the functions created with the following statements:
CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));
The returnType is {typeKind: "FLOAT64"} for Add and Decrement, and is absent for Increment (inferred as
FLOAT64 at query time).
Suppose the function Add is replaced by CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);
Then the inferred return type of Increment is automatically changed to INT64 at query time, while the
return type of Decrement remains FLOAT64.
1004 1005 1006 |
# File 'lib/google/cloud/bigquery/routine.rb', line 1004 def return_type= new_return_type @gapi.return_type = StandardSql::DataType.gapi_from_string_or_data_type new_return_type end |
#routine_type=(new_routine_type) ⇒ Object
Updates the type of routine. Required.
SCALAR_FUNCTION- Non-builtin permanent scalar function.PROCEDURE- Stored procedure.
934 935 936 |
# File 'lib/google/cloud/bigquery/routine.rb', line 934 def routine_type= new_routine_type @gapi.routine_type = new_routine_type end |
#update ⇒ Object
1078 1079 1080 |
# File 'lib/google/cloud/bigquery/routine.rb', line 1078 def update raise "not implemented in #{self.class}" end |