Titan Core
  • Overview
  • Getting Started
  • Working With Resources
  • Blueprint
  • GitHub Action
  • Resources
    • APIAuthenticationSecurityIntegration
    • APIIntegration
    • AccountParameter
    • AggregationPolicy
    • Alert
    • AuthenticationPolicy
    • AzureStorageIntegration
    • ComputePool
    • Database
    • DatabaseRole
    • DynamicTable
    • EmailNotificationIntegration
    • EventTable
    • ExternalAccessIntegration
    • ExternalStage
    • FailoverGroup
    • FutureGrant
    • GCSStorageIntegration
    • GenericSecret
    • GlueCatalogIntegration
    • Grant
    • GrantOnAll
    • HybridTable
    • ImageRepository
    • InternalStage
    • JSONFileFormat
    • JavascriptUDF
    • MaterializedView
    • NetworkPolicy
    • NetworkRule
    • OAuthSecret
    • ObjectStoreCatalogIntegration
    • PackagesPolicy
    • ParquetFileFormat
    • PasswordPolicy
    • PasswordSecret
    • Pipe
    • PythonStoredProcedure
    • PythonUDF
    • ReplicationGroup
    • ResourceMonitor
    • Role
    • RoleGrant
    • S3StorageIntegration
    • Schema
    • Sequence
    • Service
    • SessionPolicy
    • Share
    • SnowflakePartnerOAuthSecurityIntegration
    • SnowservicesOAuthSecurityIntegration
    • StageStream
    • Table
    • TableStream
    • Tag
    • Task
    • User
    • View
    • ViewStream
    • Warehouse
Powered by GitBook
On this page
  • Examples
  • Python
  • YAML
  • Fields
  1. Resources

JavascriptUDF

PreviousJSONFileFormatNextMaterializedView

Last updated 6 months ago

A Javascript user-defined function (UDF) in Snowflake allows you to define a function using the JavaScript programming language.

Examples

Python

js_udf = JavascriptUDF(
    name="some_function",
    returns="STRING",
    as_="function(x) { return x.toUpperCase(); }",
    args=[{"name": "x", "data_type": "STRING"}],
    comment="Converts a string to uppercase",
)

YAML

functions:
  - name: some_function
    returns: STRING
    as_: function(x) { return x.toUpperCase(); }
    args:
      - name: x
        data_type: STRING
    comment: Converts a string to uppercase

Fields

  • name (string, required) - The name of the function.

  • as_ (string, required) - The JavaScript code to execute when the function is called.

  • args (list) - The arguments that the function takes.

  • comment (string) - A comment for the function.

  • copy_grants (bool) - Specifies whether to retain the access privileges from the original function when a new function is created using CREATE OR REPLACE FUNCTION. Defaults to False.

  • external_access_integrations (list) - External integrations accessible by the function.

  • handler (string) - The entry point for the function within the JavaScript code.

  • imports (list) - The list of JavaScript files to import.

  • packages (list) - The list of npm packages that the function depends on.

  • runtime_version (string) - The JavaScript runtime version to use.

  • secrets (dict of string to string) - Key-value pairs of secrets available to the function.

  • secure (bool) - Specifies whether the function is secure. Defaults to False.

returns (string or , required) - The data type of the function's return value.

null_handling (string or ) - How the function handles NULL input.

owner (string or ) - The owner of the function. Defaults to "SYSADMIN".

volatility (string or ) - The volatility of the function.

Snowflake Documentation
DataType
NullHandling
Role
Volatility