Template specification¶
Defines a single template in a collaboration. Templates are registered by calling REGISTER_TEMPLATE with the template specification.
Schema:
api_versionThe version of the Collaboration API used. Must be
2.0.0.spec_typeSpecification type identifier. Must be
template.name: template_nameA unique, user-friendly name for this template. Must follow Snowflake identifier rules with a maximum of 75 characters. The
name_versionpair must be unique for all templates in this account.version: version_stringA version identifier for this template (maximum 20 characters). Must follow Snowflake identifier rules. The version string is given its own column in the response to VIEW_TEMPLATES and VIEW_REGISTERED_TEMPLATES, so use a value that can be sorted by increasing value. Example:
V0typeThe template type. One of the following values:
sql_analysis: Template for data analysis operations.sql_activation: Template for data activation operations.
description: template_description(Optional)A high-level description of what this template does (maximum 1,000 characters).
methodology: methodology_description(Optional)A more detailed description of how this template works (maximum 1,000 characters).
parameters(Optional)The list of all user-provided parameters in this template. Each item can have the following fields:
name: Parameter name as a valid Snowflake identifier, max 255 characters.description(Optional): Human-readable description of the parameter (maximum 500 characters).required(Optional): Whether the parameter is required. Default isfalse.default(Optional): Default value for the parameter, which can be any data type.type(Optional): Expected data type of the parameter. One of:string,integer,number,boolean,array, orobject.
code_specs(Optional)One or more code specs that define any functions referenced by this template. Required when the template calls custom functions. Code spec IDs are versioned; if you want to access a new version of a function, you must update the code spec ID here, but not in the template itself, which calls the unversioned function name. The code spec name must have an underscore in it, and match the regular expression pattern
[A-Za-z]\w{0,74}_\w{1,20}.preset_tables(Optional)Datasets preset by the template author. An analysis runner doesn’t pass these datasets when they run the template. Use
preset_tableswhen a template should always read a specific dataset, rather than whichever dataset the analysis runner chooses to supply. For details, see Preset tables. Each item has the following fields:alias: The name used to reference this dataset in the template body, as{{ preset_tables['alias'] }}. Must be a valid Snowflake identifier of up to 255 characters, and must be unique within the template. The SQL alias you then give the dataset in the template body can’t bep,c, orporcfollowed by a number, because those aliases are reserved forsource_tableandmy_tabledatasets.template_view_name: The preset table, in the formatcollaborator_alias.data_offering_ID.dataset_alias. Use the value from the TEMPLATE_VIEW_NAME column returned by VIEW_DATA_OFFERINGS.
templateThe template content. For SQL templates, this contains the JinjaSQL template. For more information, see Template design.
The column names exposed to the template are determined by the
categoryandcolumn_typevalues for the column in the data offering specification. For more information, see Source column renaming.
Examples¶
A template that takes one table from the analysis runner:
A template that pins the publisher’s dataset and takes the advertiser’s dataset from the analysis runner: