Jinja Reference

Snoweaver offers a variety of pre-defined variables and functions, as detailed on this page. These can be used in any Jinja-compatible components.

Note

User-defined variables, macros, and functions with identical names will override the pre-defined ones.

System Variables

The following table outlines the system variables available in Snoweaver:

Variable

Description

_sys.project

Returns the name of the current project.

_proj.[name]

Retrieves the value of a project variable.

_vars.[name]

Retrieves the value of a job variable.

_secrets.[alias]

Returns the string value of a generic secret or the token value of an OAuth secret. The value is encoded during the testing of Jinja templates.
Note: It cannot be used in prehook, endpoint, filepath, or posthook.

_secrets.[alias].username

Returns the username of a basic secret. The value is encoded during the testing of Jinja templates.
Note: It cannot be used in prehook, endpoint, filepath, or posthook.

_secrets.[alias].password

Returns the password of a basic secret. The value is encoded during the testing of Jinja templates.
Note: It cannot be used in prehook, endpoint, filepath, or posthook.

_prehook

Returns the output of the pre-hook generated by the Jinja engine.

_status

Returns the HTTP status code of the web request. Available only in post-hook.

_headers

Returns a dictionary containing the headers of the response. Available only in post-hook.

_response

Returns the response payload of the web request. Available only in post-hook.

System Functions

call_proc

args: (proc, *args)

This function invokes a procedure within the same project. It always returns a string, regardless of the type specified in the procedure instance.

  • proc: The name of the stored procedure.

  • args: The arguments for the procedure.

Note

  • To isolate environments and control access within Snoweaver, this function is only usable if the instance type is a procedure and can only invoke procedures within the same project.

  • Use a Snowflake REST API job if you need to interact with other projects or Snowflake objects. Refer to: Tutorial: Execute Snowflake statements via Rest API.

raise_exception

args: (message)

This function raises an exception in the job with the provided message. Exceptions will be captured and logged in the event table.

Example: Refer to Tutorial: Enable logging and capture errors.

now

args: (timezone=’’)

This function invokes the datetime.now Python method, returning a datetime object.

The timezone argument is optional. A comprehensive list of valid timezone values can be retrieved using the pytz.all_timezones function.

sleep

args: (seconds)

This function invokes the time.sleep Python method.

json_loads

args: (input)

This function invokes the json5.loads Python method to decodes JSON serialized data from an str object.

generate_snflk_jwt

args: ( account, key_secret, key_fp)

Generates a Snowflake JWT token with the provided values.

  • account: The identifier for your Snowflake account. Format: <your org>-<your account>.

  • key_secret: The secret containing both the user name and the assoicated private key.

  • key_fp: The fingerprint of the private key.

Example: Refer to Tutorial: Execute Snowflake statements via Rest API

generate_basic_creds

args: (user, password)

Generates a Base64 encoded value of the credentials provided for Basic access authentication

Jinja Extensions

Snoweaver comes pre-configured with the following Jinja extensions, enhancing the functionality of your Jinja environment:

  • jinja2.ext.loopcontrols: Adds break and continue control statements within loops.

  • jinja2.ext.do: Allows for the execution of arbitrary statements within templates.

  • jinja2.ext.debug: Provides debugging support within Jinja templates.