CREATE CODE BUNDLE

statementsupportedContainer services & dev tooling

docs.snowflake.com ↗

Object: CODE BUNDLE

Note Notebook Project Objects have been renamed to Code Bundles. The NOTEBOOK PROJECT grammar is still supported; for that syntax, see CREATE NOTEBOOK PROJECT. For background on the rename, see the behavior change announcement. Creates a Code Bundle: a named, schema-level object that packages your project source files (for example, .py scripts, .ipynb notebooks, and SQL files) for non-interactive execution on Snowflake compute. When the Code Bundle is created, all files from the source are copied into the object in the specified database and schema. The Code Bundle can then be executed using EXECUTE CODE BUNDLE. You can create a Code Bundle from an internal or temporary stage, a private workspace, or a shared workspace. External stages aren’t supported. To run source files once without creating a Code Bundle, use EXECUTE CODE BUNDLE FROM instead. This command supports the following variant: - DEFINE CODE BUNDLE: Declarative definition of a Code Bundle’s target state inside a DCM project.

Syntax

supportedpartialnot supportednot scored

Create a Code Bundle from a private workspace

CREATE [ OR REPLACE ] CODE BUNDLE [ IF NOT EXISTS ] <database_name>.<schema_name>.<bundle_name>
  FROM 'snow://workspace/<workspace_path>'
  [ COMMENT = '<string_literal>' ];

Create a Code Bundle from a stage

CREATE [ OR REPLACE ] CODE BUNDLE [ IF NOT EXISTS ] <database_name>.<schema_name>.<bundle_name>
  FROM '@<database_name>.<schema_name>.<stage_name>'
  [ COMMENT = '<string_literal>' ];

DEFINE CODE BUNDLE uses the same parameters as CREATE CODE BUNDLE, except FROM must be an asset:// URI that resolves to a project asset declared in the DCM project manifest

DEFINE CODE BUNDLE DEMO{{env_suffix}}.JOBS.MY_JOB
  FROM 'asset://my_job'
  COMMENT = 'Python job managed by DCM';

Parameters

NameRequiredDescription
database_name.schema_name.bundle_namerequiredFully qualified identifier for the Code Bundle. The bundle name must be unique within the schema. Identifiers must start with an alphabetic character and cannot contain spaces or special characters unless the identifier is enclosed in double quotes (for example, "My Bundle"). Identifiers in double quotes are case-sensitive.
FROM { 'snow://workspace/workspace_path' | '@database_name.schema_name.stage_name' }requiredSpecifies the source that backs this Code Bundle. Use a snow://workspace/... URL to create the Code Bundle from a workspace version in Snowsight. Use a stage reference (for example, '@my_db.my_schema.my_stage') to create the Code Bundle from files that you have deployed to an internal or temporary stage. When creating from a workspace, the value must be a snow://workspace/... URL pointing to a workspace version. The path typically includes: USER$ or another owner. Schema. Workspace name. Version (for example, versions/last). For example: snow://workspace/USER$.MY_SCHEMA."my_workspace"/versions/last
COMMENT = 'string_literal'optionalAdds a comment or description to the Code Bundle. Use comments to describe the purpose or workflow (for example, COMMENT = 'Code Bundle for this workflow'). Comments are stored as object metadata; avoid including sensitive data in comments.

Usage notes

Access control requirements

To execute CREATE CODE BUNDLE, a role must have sufficient privileges to create objects in the target database and schema. Required privileges include: - USAGE or OWNERSHIP on the database. - USAGE or OWNERSHIP on the schema. - CREATE CODE BUNDLE on the schema that allows creating objects within that schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

See also

Referenced by