Update and upgrade a Snowflake Native App

The Snowflake Native App Framework enables providers to update a Snowflake Native App to add new functionality, fix bugs, and make other changes. This topic describes how to add versions and patches to an application package. It also describes how to upgrade installed instances of a Snowflake Native App.

About versions and patches

Within the context of the Snowflake Native App Framework, version and patch refer to the following:

Version

Generally contains major updates to a Snowflake Native App. Versions are defined in an application package. An application package can only have two active versions at one time. To add a new version to an application package that already has two versions defined, you must first drop one of the versions.

Patch

Generally contains smaller updates to a Snowflake Native App. Like versions, patches are defined in the application package. Although an application package can only contain two active versions at one time, a single version can have multiple patches.

Note

A single version can have up to 130 patches.

When a provider adds a new version to an application package, the new version is automatically assigned patch 0. When a provider adds a new patch to a version, they can manually specify the patch number. If no patch number is provided, Snowflake automatically increments the patch version by 1.

After adding a version or patch to an application package, you can test the changes locally by creating an application object based on the version or patch. See Create an application object from a version or patch level for more information.

Note

Each version and patch defined in an application package must have its own version of the setup script and application files.

Differences between versions and patches

When a provider publishes a new version of an app, the Snowflake Native App Framework ensures that only the previous version of the app is active. For example, if a provider has published V1 and V2 of an app, the Snowflake Native App Framework ensures that only V2 is currently installed in a consumer account before upgrading to V3. This ensures that the setup script only has to account for differences between V2 and V3. In other words, the setup script is only backwards compatible with the most recent version of the app. If a provider makes a state change to the app, for example creating a new table or adding columns to a table, there are no compatibility issues between versions.

In contrast, when a provider publishes a new patch for a version of an app, the Snowflake Native App Framework does not enforce any restrictions on the number of active patches running. Providers must avoid making changes to the state of an app in a patch.

About release directives

A release directive specifies the version, and optionally, the patch, that is used when a consumer installs a Snowflake Native App. Release directives are also used to trigger an automated upgrade across all installed instances of a specific version or patch.

Release directives are defined in the application package. There are two types of release directives:

Custom release directive

Allows a provider to specify the version of an application that specific Snowflake accounts can install. See add a custom release directive for more information.

Default release directive

Specifies the version and patch that is applicable to all consumers when installing a Snowflake Native App. If a provider creates versions V1 and V2 of an application, setting the default release directive to V2 ensures that when a consumer installs the Snowflake Native App, they install the V2 version. See set a default release directive for more information.

If a provider create version V2 and V3 of an application, they can assign V2 to be the default release and create a custom release directive to share V3 only with specific accounts. A provider may also share version V3 of the application with a test account before publishing that version.

Note

If you specify both a default and custom release directive, the custom release directive always takes precedence. In the example above, consumer accounts specified in the custom release directive would only be able to install V3 of the application.

You must define a release directive in an application package before you can perform the following tasks:

  • Create a public listing with the application package as the data content.

  • Install a Snowflake Native App in a consumer account.

About upgrades

Within the context of the Snowflake Native App Framework, upgrades are updates to a version or patch of a Snowflake Native App that is installed in the consumer account. The Snowflake Native App Framework supports two types of upgrades:

Automated upgrades

Automated upgrades are upgrades that are initiated by the provider. When a new version or patch is available, the provider modifies the release directive on the application package. This triggers an automatic upgrade of all installed instances of the app specified by the release directive.

Manual upgrades

Manual upgrades are upgrades that are initiated by the consumer in response to communication from the provider. Manual upgrades are useful when a provider needs to quickly release an update, for example a bug fix, to a consumer.

When a new version or patch is available, the provider modifies the release directive on the application package, then the provider notifies the consumer that a new version is available. The consumer then performs the upgrade by running the ALTER APPLICATION command to perform the upgrade. In general, manual upgrades allow the consumer to upgrade their installed app faster than automated upgrades.

For information on the workflow for performing an upgrade, see Upgrade a Snowflake Native App.

About upgrades across regions

See Upgrade an installed app across multiple regions for information on upgrading an installed app across regions.

Add a version or patch to an application package

Version information for an application is specified in the application package.

Privileges required to add or remove versions and patches

To specify a version or patch for an application package, you must have one of the following privileges granted on the application package to your role:

  • OWNERSHIP

  • MANAGE VERSIONS

For example, to grant the MANAGE VERSION privilege on the application package to the release_mgr role, use the GRANT <privileges> command as shown in the following example:

GRANT MANAGE VERSIONS ON APPLICATION PACKAGE hello_snowflake_package
  TO ROLE release_mgr;
Copy

Add a version to an application package by using SQL

The following example shows how to use the ALTER APPLICATION PACKAGE command to add a version to an application package.

ALTER APPLICATION PACKAGE MyAppPackage
  ADD VERSION v1_0
  USING '@dev_stage/v1_0'
  LABEL = 'MyApp Version 1.0';
Copy

In this example, v1_0 is an identifier for the version that is not visible to consumers when they install the application. The consumer sees version information as defined in the LABEL clause.

Only two versions of an application can exist at the same time. For example, if you define v1_0 and v1_1 in an application, you must drop v1_0 in order to create v1_2. However, you can have multiple patches for a single version.

You can define the version name and label in the manifest.yml file, or specify them directly with the ALTER APPLICATION PACKAGE command. If you define them in the manifest.yml file as well as with the SQL command, the values specified in the SQL command take precedence over the values specified in the manifest.yml file.

Add a patch to an application package by using SQL

In addition to creating versions for an app you can also create patches for a specific version. Like versions, app patches also have their own application files.

To create a new patch for an application package, use the ADD PATCH FOR VERSION clause of the ALTER APPLICATION PACKAGE … VERSION command, as shown in the following example:

ALTER APPLICATION PACKAGE MyAppPackage
 ADD PATCH FOR VERSION V1_0
 USING '@dev_stage/v1_0_p1;
Copy

In the example, no patch number is provided to the ADD PATCH FOR VERSION V1_0 clause. In this case Snowflake automatically increments the patch number by 1.

To create a new patch for an application with a custom patch number, provide a patch number to the ADD PATCH FOR VERSION clause of the ALTER APPLICATION PACKAGE … VERSION command, as shown in the following example:

ALTER APPLICATION PACKAGE MyAppPackage
 ADD PATCH 3
 FOR VERSION V1_0
 USING '@dev_stage/v1_0_p1;
Copy

View the versions and patches for an application package

As a provider, you can view the versions and patches defined for an application by running the SHOW VERSIONS command on the application package.

The following command displays the versions and patches that have been defined for an application package named hello_snowflake_package:

SHOW VERSIONS IN APPLICATION PACKAGE hello_snowflake_package;
Copy

Remove a version from an application package

To remove a version from an application package, you must verify that there are no release directives currently pointing that the version you want to remove.

To view the release directives specified in an application package, run the SHOW RELEASE DIRECTIVES command as shown in the following example:

SHOW RELEASE DIRECTIVES IN APPLICATION PACKAGE hello_snowflake_package;
Copy

To remove a version from an application package, use the DROP VERSION clause of the ALTER APPLICATION PACKAGE command as shown in the following example:

ALTER APPLICATION PACKAGE hello_snowflake_package
  DROP VERSION v1_0;
Copy

After running this command the version is not dropped until all installed instances of the app are dropped. To verify the the status of the drop command, use the SHOW VERSIONS as shown in the following example:

SHOW VERSIONS IN APPLICATION PACKAGE hello_snowflake_package;
Copy

The dropped_on column lists the timestamp when the drop was initiated.

Note

The dropped version only appears in the output of this command while the status is DROPPED. When all installed instances of the app are dropped, the dropped version no longer appears.

When a version is dropped, consumers can no longer install new instances of that version of the app.

Depending on how the application is published to consumers, it can take different amounts of time for the version to be dropped:

  • If the application package has not been published to consumers, the version is dropped immediately.

  • If the application package has been published as a public or private listing within a single region, the version is dropped immediately.

  • If the application package is published as the data product of a listing shared within the same region as the application package, the version is dropped within a few hours.

  • If the application package is published as the data product of a listing using Cross-Cloud Auto-Fulfillment, it may take longer for the version to be dropped across all regions.

Set the release directive for an application package

After adding a version to an application package, you can specify the release directives for the application package. Release directives determine the version of the application that is available to a consumer when they install the app or when an installed app is automatically upgraded.

Privileges required to set the release directive

To set a release directive, a provider must have the MANAGE RELEASES privilege or ownership of the application package.

GRANT MANAGE RELEASES ON APPLICATION PACKAGE hello_snowflake_package
  TO ROLE release_mgr;
Copy

Set the default release directive for an application package

Use the ALTER APPLICATION PACKAGE command with SET DEFAULT RELEASE DIRECTIVE to set the default release directive as shown in the following example:

ALTER APPLICATION PACKAGE hello_snowflake_package
  SET DEFAULT RELEASE DIRECTIVE
  VERSION = v1_0
  PATCH = 2;
Copy

To update the default release directive for an application package, run the ALTER APPLICATION PACKAGE command with SET DEFAULT RELEASE DIRECTIVE again, specifying new values for VERSION or PATCH, as appropriate.

Set a custom release directive for an application package

To add a custom release directive, use the ALTER APPLICATION PACKAGE command with SET RELEASE DIRECTIVE. Use the ACCOUNTS clause to specify the accounts to which this release directive applies. For example:

ALTER APPLICATION PACKAGE hello_snowflake_package
  SET RELEASE DIRECTIVE hello_snowflake_package_custom
  ACCOUNTS = (CONSUMER_ORG.CONSUMER_ACCOUNT)
  VERSION = v1_0
  PATCH = 0;
Copy

Update a custom release directive

To update the version or patch for a custom release directive, use the ALTER APPLICATION PACKAGE command with MODIFY RELEASE DIRECTIVE as shown in the following example:

ALTER APPLICATION PACKAGE hello_snowflake_package
  MODIFY RELEASE DIRECTIVE hello_snowflake_package_custom
  VERSION = v1_0
  PATCH = 0;
Copy

However, you cannot modify the accounts associated with the release directive. To change the organization and account associated with a release directive do the following:

  1. Remove the release directive from the application package by running the ALTER APPLICATION PACKAGE command with UNSET RELEASE DIRECTIVE.

  2. Add the release directive back to the application package by running the ALTER APPLICATION PACKAGE command with SET RELEASE DIRECTIVE and using the ACCOUNTS clause to specify the list of accounts.

Note

When changing the organization and account associated with the release directive, ensure that you add the release new release direct immediately after removing the old one. If you do not, the installed apps for the accounts assigned to the custom release directive will revert to default release directive.

Remove a custom release directive

To remove a custom release directive from an application package, use the ALTER APPLICATION PACKAGE command with UNSET RELEASE DIRECTIVE as shown in the following example:

ALTER APPLICATION PACKAGE hello_snowflake_package
  UNSET RELEASE DIRECTIVE hello_snowflake_package_custom;
Copy

Test a version and patch using a release directive

When installing an application from an application package in development mode, the version and patch are explicitly specified. However, when the application is installed using the following command:

CREATE APPLICATION hello_snowflake
  FROM APPLICATION PACKAGE hello_snowflake_package
Copy

The release directive determines the version that is installed when running this command.

Upgrade a Snowflake Native App

An upgrade is initiated when the provider sets or changes the release directive on the application package.

Workflow for upgrading an Snowflake Native App

A provider upgrades an installed app by using the following workflow:

  1. Update the application logic and setup script of the application package.

  2. If there are two versions currently defined, remove a version from the application package.

  3. Create a new version or patch for the changes in the application package.

    If the DISTRIBUTION property of the application is set to EXTERNAL, the automated security scan is initiated. The security scan must pass before the upgrade can occur.

  4. Test the new version by creating an APPLICATION object in the provider’s test account.

  5. Update the release directive for the version or patch.

    This initiates an automated upgrade that will update all installed instances of the previous version. A provider can notify the consumer that an upgrade is available and ask them to perform manually perform a manual upgrade.

Note

After upgrading an application package, changes to the installed Snowflake Native App in the consumer account might not be visible until the refresh to remote regions is performed.

You can use the APPLICATION_STATE view in the DATA_SHARING_USAGE schema to monitor the status. If the upgrade is not complete more than 1 day after the first refresh following the upgrade, there might be an issue with the refresh process. Contact Snowflake Support.

Upgrade an installed app across multiple regions

If a provider publishes a Snowflake Native App using Cross-Cloud Auto-Fulfillment, automated upgrades may take a while to upgrade depending on the following factors:

  • The value of the refresh schedule.

  • The number of installed instances of the app.

  • The number of regions where the app is deployed.

If the upgrade contains an urgent fix that needs to be upgraded in a remote region, providers can consider the following ways to perform an upgrade faster:

Perform a manual upgrade for an installed app

Manual upgrades allow a consumer to initiate the upgrade of an installed version or patch of an app using the release directive specified in the application package.

To upgrade an installed Snowflake Native App to the latest available version, a consumer can use the UPGRADE clause of the ALTER APPLICATION command to modify the application object:

ALTER APPLICATION <name> UPGRADE
Copy

View the status of an upgrade

To view the upgrade state of a app, use the APPLICATION_STATE View system view as shown in the following example:

SELECT * FROM snowflake.data_sharing_usage.APPLICATION_STATE
Copy

This view includes columns that are specific to upgrades, including the upgrade state and the region where the app is deployed.