Function

Import

format is database name | schema name | function name | <list of arg types, separated with ‘-'>

 $ pulumi import snowflake:index/function:Function example 'dbName|schemaName|functionName|varchar-varchar-varchar'

Example Usage

Coming soon!

Coming soon!

package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.snowflake.Database;
import com.pulumi.snowflake.DatabaseArgs;
import com.pulumi.snowflake.Schema;
import com.pulumi.snowflake.SchemaArgs;
import com.pulumi.snowflake.Function;
import com.pulumi.snowflake.FunctionArgs;
import com.pulumi.snowflake.inputs.FunctionArgumentArgs;
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 db = new Database("db", DatabaseArgs.builder()        
            .dataRetentionDays(1)
            .build());

        var schema = new Schema("schema", SchemaArgs.builder()        
            .database(db.name())
            .dataRetentionDays(1)
            .build());

        var testFunctJava = new Function("testFunctJava", FunctionArgs.builder()        
            .database("MY_DB")
            .schema("MY_SCHEMA")
            .arguments(FunctionArgumentArgs.builder()
                .name("arg1")
                .type("number")
                .build())
            .comment("Example for java language")
            .returnType("varchar")
            .language("java")
            .handler("CoolFunc.test")
            .statement("class CoolFunc {public static String test(int n) {return \"hello!\";}}")
            .build());

        var pythonTest = new Function("pythonTest", FunctionArgs.builder()        
            .database("MY_DB")
            .schema("MY_SCHEMA")
            .arguments(FunctionArgumentArgs.builder()
                .name("arg1")
                .type("number")
                .build())
            .comment("Example for Python language")
            .returnType("NUMBER(38,0)")
            .nullInputBehavior("CALLED ON NULL INPUT")
            .returnBehavior("VOLATILE")
            .language("python")
            .runtimeVersion("3.8")
            .handler("add_py")
            .statement("def add_py(i): return i+1")
            .build());

    }
}

Coming soon!

Coming soon!

resources:
  # Create database
  db:
    type: snowflake:Database
    properties:
      dataRetentionDays: 1
  # Create schema
  schema:
    type: snowflake:Schema
    properties:
      database: ${db.name}
      dataRetentionDays: 1
  # Example for Java language
  testFunctJava:
    type: snowflake:Function
    properties:
      database: MY_DB
      schema: MY_SCHEMA
      arguments:
        - name: arg1
          type: number
      comment: Example for java language
      returnType: varchar
      language: java
      handler: CoolFunc.test
      statement: class CoolFunc {public static String test(int n) {return "hello!";}}
  # Example for Python language
  pythonTest:
    type: snowflake:Function
    properties:
      database: MY_DB
      schema: MY_SCHEMA
      arguments:
        - name: arg1
          type: number
      comment: Example for Python language
      returnType: NUMBER(38,0)
      nullInputBehavior: CALLED ON NULL INPUT
      returnBehavior: VOLATILE
      language: python
      runtimeVersion: 3.8
      handler: add_py
      statement: 'def add_py(i): return i+1'

Create Function Resource

new Function(name: string, args: FunctionArgs, opts?: CustomResourceOptions);
@overload
def Function(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             arguments: Optional[Sequence[FunctionArgumentArgs]] = None,
             comment: Optional[str] = None,
             database: Optional[str] = None,
             handler: Optional[str] = None,
             imports: Optional[Sequence[str]] = None,
             language: Optional[str] = None,
             name: Optional[str] = None,
             null_input_behavior: Optional[str] = None,
             packages: Optional[Sequence[str]] = None,
             return_behavior: Optional[str] = None,
             return_type: Optional[str] = None,
             runtime_version: Optional[str] = None,
             schema: Optional[str] = None,
             statement: Optional[str] = None,
             target_path: Optional[str] = None)
@overload
def Function(resource_name: str,
             args: FunctionArgs,
             opts: Optional[ResourceOptions] = None)
func NewFunction(ctx *Context, name string, args FunctionArgs, opts ...ResourceOption) (*Function, error)
public Function(string name, FunctionArgs args, CustomResourceOptions? opts = null)
public Function(String name, FunctionArgs args)
public Function(String name, FunctionArgs args, CustomResourceOptions options)
type: snowflake:Function
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args FunctionArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Function Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Function resource accepts the following input properties:

Database string

The database in which to create the function. Don't use the | character.

ReturnType string

The return type of the function

Schema string

The schema in which to create the function. Don't use the | character.

Statement string

Specifies the javascript / java / sql / python code used to create the function.

Arguments List<FunctionArgumentArgs>

List of the arguments for the function

Comment string

Specifies a comment for the function.

Handler string

The handler method for Java / Python function.

Imports List<string>

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

Language string

The language of the statement

Name string

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

NullInputBehavior string

Specifies the behavior of the function when called with null inputs.

Packages List<string>

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

ReturnBehavior string

Specifies the behavior of the function when returning results

RuntimeVersion string

Required for Python functions. Specifies Python runtime version.

TargetPath string

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

Database string

The database in which to create the function. Don't use the | character.

ReturnType string

The return type of the function

Schema string

The schema in which to create the function. Don't use the | character.

Statement string

Specifies the javascript / java / sql / python code used to create the function.

Arguments []FunctionArgumentArgs

List of the arguments for the function

Comment string

Specifies a comment for the function.

Handler string

The handler method for Java / Python function.

Imports []string

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

Language string

The language of the statement

Name string

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

NullInputBehavior string

Specifies the behavior of the function when called with null inputs.

Packages []string

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

ReturnBehavior string

Specifies the behavior of the function when returning results

RuntimeVersion string

Required for Python functions. Specifies Python runtime version.

TargetPath string

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

database String

The database in which to create the function. Don't use the | character.

returnType String

The return type of the function

schema String

The schema in which to create the function. Don't use the | character.

statement String

Specifies the javascript / java / sql / python code used to create the function.

arguments List<FunctionArgumentArgs>

List of the arguments for the function

comment String

Specifies a comment for the function.

handler String

The handler method for Java / Python function.

imports List<String>

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language String

The language of the statement

name String

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

nullInputBehavior String

Specifies the behavior of the function when called with null inputs.

packages List<String>

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

returnBehavior String

Specifies the behavior of the function when returning results

runtimeVersion String

Required for Python functions. Specifies Python runtime version.

targetPath String

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

database string

The database in which to create the function. Don't use the | character.

returnType string

The return type of the function

schema string

The schema in which to create the function. Don't use the | character.

statement string

Specifies the javascript / java / sql / python code used to create the function.

arguments FunctionArgumentArgs[]

List of the arguments for the function

comment string

Specifies a comment for the function.

handler string

The handler method for Java / Python function.

imports string[]

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language string

The language of the statement

name string

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

nullInputBehavior string

Specifies the behavior of the function when called with null inputs.

packages string[]

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

returnBehavior string

Specifies the behavior of the function when returning results

runtimeVersion string

Required for Python functions. Specifies Python runtime version.

targetPath string

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

database str

The database in which to create the function. Don't use the | character.

return_type str

The return type of the function

schema str

The schema in which to create the function. Don't use the | character.

statement str

Specifies the javascript / java / sql / python code used to create the function.

arguments Sequence[FunctionArgumentArgs]

List of the arguments for the function

comment str

Specifies a comment for the function.

handler str

The handler method for Java / Python function.

imports Sequence[str]

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language str

The language of the statement

name str

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

null_input_behavior str

Specifies the behavior of the function when called with null inputs.

packages Sequence[str]

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

return_behavior str

Specifies the behavior of the function when returning results

runtime_version str

Required for Python functions. Specifies Python runtime version.

target_path str

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

database String

The database in which to create the function. Don't use the | character.

returnType String

The return type of the function

schema String

The schema in which to create the function. Don't use the | character.

statement String

Specifies the javascript / java / sql / python code used to create the function.

arguments List<Property Map>

List of the arguments for the function

comment String

Specifies a comment for the function.

handler String

The handler method for Java / Python function.

imports List<String>

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language String

The language of the statement

name String

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

nullInputBehavior String

Specifies the behavior of the function when called with null inputs.

packages List<String>

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

returnBehavior String

Specifies the behavior of the function when returning results

runtimeVersion String

Required for Python functions. Specifies Python runtime version.

targetPath String

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

Outputs

All input properties are implicitly available as output properties. Additionally, the Function resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing Function Resource

Get an existing Function resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: FunctionState, opts?: CustomResourceOptions): Function
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arguments: Optional[Sequence[FunctionArgumentArgs]] = None,
        comment: Optional[str] = None,
        database: Optional[str] = None,
        handler: Optional[str] = None,
        imports: Optional[Sequence[str]] = None,
        language: Optional[str] = None,
        name: Optional[str] = None,
        null_input_behavior: Optional[str] = None,
        packages: Optional[Sequence[str]] = None,
        return_behavior: Optional[str] = None,
        return_type: Optional[str] = None,
        runtime_version: Optional[str] = None,
        schema: Optional[str] = None,
        statement: Optional[str] = None,
        target_path: Optional[str] = None) -> Function
func GetFunction(ctx *Context, name string, id IDInput, state *FunctionState, opts ...ResourceOption) (*Function, error)
public static Function Get(string name, Input<string> id, FunctionState? state, CustomResourceOptions? opts = null)
public static Function get(String name, Output<String> id, FunctionState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Arguments List<FunctionArgumentArgs>

List of the arguments for the function

Comment string

Specifies a comment for the function.

Database string

The database in which to create the function. Don't use the | character.

Handler string

The handler method for Java / Python function.

Imports List<string>

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

Language string

The language of the statement

Name string

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

NullInputBehavior string

Specifies the behavior of the function when called with null inputs.

Packages List<string>

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

ReturnBehavior string

Specifies the behavior of the function when returning results

ReturnType string

The return type of the function

RuntimeVersion string

Required for Python functions. Specifies Python runtime version.

Schema string

The schema in which to create the function. Don't use the | character.

Statement string

Specifies the javascript / java / sql / python code used to create the function.

TargetPath string

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

Arguments []FunctionArgumentArgs

List of the arguments for the function

Comment string

Specifies a comment for the function.

Database string

The database in which to create the function. Don't use the | character.

Handler string

The handler method for Java / Python function.

Imports []string

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

Language string

The language of the statement

Name string

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

NullInputBehavior string

Specifies the behavior of the function when called with null inputs.

Packages []string

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

ReturnBehavior string

Specifies the behavior of the function when returning results

ReturnType string

The return type of the function

RuntimeVersion string

Required for Python functions. Specifies Python runtime version.

Schema string

The schema in which to create the function. Don't use the | character.

Statement string

Specifies the javascript / java / sql / python code used to create the function.

TargetPath string

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

arguments List<FunctionArgumentArgs>

List of the arguments for the function

comment String

Specifies a comment for the function.

database String

The database in which to create the function. Don't use the | character.

handler String

The handler method for Java / Python function.

imports List<String>

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language String

The language of the statement

name String

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

nullInputBehavior String

Specifies the behavior of the function when called with null inputs.

packages List<String>

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

returnBehavior String

Specifies the behavior of the function when returning results

returnType String

The return type of the function

runtimeVersion String

Required for Python functions. Specifies Python runtime version.

schema String

The schema in which to create the function. Don't use the | character.

statement String

Specifies the javascript / java / sql / python code used to create the function.

targetPath String

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

arguments FunctionArgumentArgs[]

List of the arguments for the function

comment string

Specifies a comment for the function.

database string

The database in which to create the function. Don't use the | character.

handler string

The handler method for Java / Python function.

imports string[]

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language string

The language of the statement

name string

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

nullInputBehavior string

Specifies the behavior of the function when called with null inputs.

packages string[]

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

returnBehavior string

Specifies the behavior of the function when returning results

returnType string

The return type of the function

runtimeVersion string

Required for Python functions. Specifies Python runtime version.

schema string

The schema in which to create the function. Don't use the | character.

statement string

Specifies the javascript / java / sql / python code used to create the function.

targetPath string

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

arguments Sequence[FunctionArgumentArgs]

List of the arguments for the function

comment str

Specifies a comment for the function.

database str

The database in which to create the function. Don't use the | character.

handler str

The handler method for Java / Python function.

imports Sequence[str]

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language str

The language of the statement

name str

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

null_input_behavior str

Specifies the behavior of the function when called with null inputs.

packages Sequence[str]

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

return_behavior str

Specifies the behavior of the function when returning results

return_type str

The return type of the function

runtime_version str

Required for Python functions. Specifies Python runtime version.

schema str

The schema in which to create the function. Don't use the | character.

statement str

Specifies the javascript / java / sql / python code used to create the function.

target_path str

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

arguments List<Property Map>

List of the arguments for the function

comment String

Specifies a comment for the function.

database String

The database in which to create the function. Don't use the | character.

handler String

The handler method for Java / Python function.

imports List<String>

Imports for Java / Python functions. For Java this a list of jar files, for Python this is a list of Python files.

language String

The language of the statement

name String

Specifies the identifier for the function; does not have to be unique for the schema in which the function is created. Don't use the | character.

nullInputBehavior String

Specifies the behavior of the function when called with null inputs.

packages List<String>

List of package imports to use for Java / Python functions. For Java, package imports should be of the form: packagename:versionnumber, where packagename is snowflakedomain:package. For Python use it should be: ('numpy','pandas','xgboost==1.5.0').

returnBehavior String

Specifies the behavior of the function when returning results

returnType String

The return type of the function

runtimeVersion String

Required for Python functions. Specifies Python runtime version.

schema String

The schema in which to create the function. Don't use the | character.

statement String

Specifies the javascript / java / sql / python code used to create the function.

targetPath String

The target path for the Java / Python functions. For Java, it is the path of compiled jar files and for the Python it is the path of the Python files.

Supporting Types

FunctionArgument

Name string

The argument name

Type string

The argument type

Name string

The argument name

Type string

The argument type

name String

The argument name

type String

The argument type

name string

The argument name

type string

The argument type

name str

The argument name

type str

The argument type

name String

The argument name

type String

The argument type

Package Details

Repository
https://github.com/pulumi/pulumi-snowflake
License
Apache-2.0
Notes

This Pulumi package is based on the snowflake Terraform Provider.