Code bundle specification¶
This specification defines a bundle of one or more code functions or procedures that can be called by a template.
A code bundle spec can contain a combined maximum of 5 functions and procedures.
For examples of different kinds of code bundles, see Example specs.
Identifiers in the code bundle spec have the following general requirements:
Names: Must be valid Snowflake identifiers that start with a letter and contain only alphanumeric characters and underscores.
Quoted identifiers: Double-quoted identifiers are supported for names with special characters.
Case sensitivity: Unquoted identifiers are case-insensitive; quoted identifiers preserve case.
api_versionThe version of the Collaboration API used. Must be
2.0.0.spec_typeSpecification type identifier. Must be
code_spec.name: identifierA unique name for this code bundle spec within this registry. Must be a valid Snowflake identifier with a maximum of 75 characters. This is used as the last name segment when calling the function in a template:
cleanroom.code_spec_name$function_nameversion: version_idCustom version identifier. Must be alphanumeric with underscores, maximum 20 characters.
description: description_text(Optional)A description of the code bundle spec (maximum 1,000 characters).
artifacts(Optional)A list of staged files or packages that can be imported by your functions or procedures, and optionally exposed via handler functions. Maximum of 5 per spec.
alias: identifierAn alias for referencing this artifact in imports. When referencing this alias within this spec, use the bare alias name rather than
cleanroom.spec_name$alias; that is, use the bare function name to reference another function in this spec.stage_path: stage_pathFull stage path to the artifact file. For example,
@DB.SCHEMA.STAGE/path/file.whl.
The stage must be internal. External stages aren’t supported.
The stage must have DIRECTORY enabled: The stage containing artifacts must have
DIRECTORY = TRUEset.Stage path format: Must follow
@[DB.]SCHEMA.STAGE/path/to/file.extformat.No path traversal: Stage paths can’t contain
..or\.This artifact must exist: The file must exist at the specified stage path when the code bundle is registered.
The stage must have SNOWFLAKE_SSE server-side encryption enabled. When creating or altering the stage, set
ENCRYPTION = (TYPE = 'SNOWFLAKE_SSE').If you push, delete, or update a staged code file, you must call
ALTER STAGE stage name REFRESHto ensure that the collaboration has the latest information from the stage. Code updates are supported only before you register the code spec, as this is when the version is assigned and the hash checksum calculated.
description: description_text(Optional)A description of the artifact (maximum 500 characters).
content_hash: sha256_hash(Optional)Lowercase SHA-256 hash for integrity verification (64 hex characters).
functions(Required if no procedures are defined)A list of UDF or UDTF definitions.
name: identifierThe function name to expose to the calling template. Must be a valid Snowflake identifier.
typeThe function type. One of
UDForUDTF.languageThe function language. Currently only
PYTHONis supported.runtime_version: python_version(Optional)Python runtime version to use. Supported versions:
3.10to3.14.handler: handlerThe name of the handler function in the function code to call when
nameis called.arguments(Optional)Function arguments as a list of name-type pairs. Types must be valid Snowflake SQL types.
returns: sql_typeThe return type. For UDFs, use a SQL type such as STRING or FLOAT. For UDTFs, use
TABLE(column_definitions).packages(Optional)A list of packages used by this code. This can be any of these Anaconda Python packages or these Snowpark API packages. For example:
snowflake-snowpark-python,numpy.imports(Optional)A list of artifacts to import. These must be aliases from the artifacts list in this spec.
code_body(Optional)Inline Python code. Mutually exclusive with staged imports. Maximum size is 12 MB.
description: description_text(Optional)A description of the function (maximum 500 characters).
procedures(Required if no functions defined)A list of stored procedure definitions. Fields are similar to
functions, except there is notypefield.