Routine

class Routine : KotlinCustomResource

A user-defined function or a stored procedure that belongs to a Dataset To get more information about Routine, see:

Example Usage

Big Query Routine Basic

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigquery.Dataset;
import com.pulumi.gcp.bigquery.DatasetArgs;
import com.pulumi.gcp.bigquery.Routine;
import com.pulumi.gcp.bigquery.RoutineArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test = new Dataset("test", DatasetArgs.builder()
.datasetId("dataset_id")
.build());
var sproc = new Routine("sproc", RoutineArgs.builder()
.datasetId(test.datasetId())
.routineId("routine_id")
.routineType("PROCEDURE")
.language("SQL")
.definitionBody("CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);")
.build());
}
}

Big Query Routine Json

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigquery.Dataset;
import com.pulumi.gcp.bigquery.DatasetArgs;
import com.pulumi.gcp.bigquery.Routine;
import com.pulumi.gcp.bigquery.RoutineArgs;
import com.pulumi.gcp.bigquery.inputs.RoutineArgumentArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test = new Dataset("test", DatasetArgs.builder()
.datasetId("dataset_id")
.build());
var sproc = new Routine("sproc", RoutineArgs.builder()
.datasetId(test.datasetId())
.routineId("routine_id")
.routineType("SCALAR_FUNCTION")
.language("JAVASCRIPT")
.definitionBody("CREATE FUNCTION multiplyInputs return x*y;")
.arguments(
RoutineArgumentArgs.builder()
.name("x")
.dataType("{\"typeKind\" : \"FLOAT64\"}")
.build(),
RoutineArgumentArgs.builder()
.name("y")
.dataType("{\"typeKind\" : \"FLOAT64\"}")
.build())
.returnType("{\"typeKind\" : \"FLOAT64\"}")
.build());
}
}

Big Query Routine Tvf

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigquery.Dataset;
import com.pulumi.gcp.bigquery.DatasetArgs;
import com.pulumi.gcp.bigquery.Routine;
import com.pulumi.gcp.bigquery.RoutineArgs;
import com.pulumi.gcp.bigquery.inputs.RoutineArgumentArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test = new Dataset("test", DatasetArgs.builder()
.datasetId("dataset_id")
.build());
var sproc = new Routine("sproc", RoutineArgs.builder()
.datasetId(test.datasetId())
.routineId("routine_id")
.routineType("TABLE_VALUED_FUNCTION")
.language("SQL")
.definitionBody("""
SELECT 1 + value AS value
""")
.arguments(RoutineArgumentArgs.builder()
.name("value")
.argumentKind("FIXED_TYPE")
.dataType(serializeJson(
jsonObject(
jsonProperty("typeKind", "INT64")
)))
.build())
.returnTableType(serializeJson(
jsonObject(
jsonProperty("columns", jsonArray(jsonObject(
jsonProperty("name", "value"),
jsonProperty("type", jsonObject(
jsonProperty("typeKind", "INT64")
))
)))
)))
.build());
}
}

Import

Routine can be imported using any of these accepted formats

$ pulumi import gcp:bigquery/routine:Routine default projects/{{project}}/datasets/{{dataset_id}}/routines/{{routine_id}}
$ pulumi import gcp:bigquery/routine:Routine default {{project}}/{{dataset_id}}/{{routine_id}}
$ pulumi import gcp:bigquery/routine:Routine default {{dataset_id}}/{{routine_id}}

Properties

Link copied to clipboard

Input/output argument of a function or a stored procedure. Structure is documented below.

Link copied to clipboard
val creationTime: Output<Int>

The time when this routine was created, in milliseconds since the epoch.

Link copied to clipboard
val datasetId: Output<String>

The ID of the dataset containing this routine

Link copied to clipboard
val definitionBody: Output<String>

The body of the routine. For functions, this is the expression in the AS clause. If language=SQL, it is the substring inside (but excluding) the parentheses.

Link copied to clipboard
val description: Output<String>?

The description of the routine if defined.

Link copied to clipboard
val determinismLevel: Output<String>?

The determinism level of the JavaScript UDF if defined. Possible values are: DETERMINISM_LEVEL_UNSPECIFIED, DETERMINISTIC, NOT_DETERMINISTIC.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.

Link copied to clipboard
val language: Output<String>?

The language of the routine. Possible values are: SQL, JAVASCRIPT.

Link copied to clipboard
val lastModifiedTime: Output<Int>

The time when this routine was modified, in milliseconds since the epoch.

Link copied to clipboard
val project: Output<String>

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val returnTableType: Output<String>?

Optional. Can be set only if routineType = "TABLE_VALUED_FUNCTION". If absent, the return table type is inferred from definitionBody at query time in each query that references this routine. If present, then the columns in the evaluated table result will be cast to match the column types specificed in return table type, at query time.

Link copied to clipboard
val returnType: Output<String>?

A JSON schema for the return type. Optional if language = "SQL"; required otherwise. If absent, the return type is inferred from definitionBody 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. ~>NOTE: Because this field expects a JSON string, any changes to the string will create a diff, even if the JSON itself hasn't changed. If the API returns a different value for the same schema, e.g. it switche d the order of values or replaced STRUCT field type with RECORD field type, we currently cannot suppress the recurring diff this causes. As a workaround, we recommend using the schema as returned by the API.

Link copied to clipboard
val routineId: Output<String>

The ID of the the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.

Link copied to clipboard
val routineType: Output<String>?

The type of routine. Possible values are: SCALAR_FUNCTION, PROCEDURE, TABLE_VALUED_FUNCTION.

Link copied to clipboard
val urn: Output<String>