Use remote app operations¶
About remote app operations¶
Remote app operations let a provider perform different types of operations on the consumer Snowflake Native App, such as running on-demand SQL statements for troubleshooting or disabling the application.
Currently, the supported operation types are run_sql, disable, enable, and retry_upgrade:
| Operation Type | Description | Consent Required? |
|---|---|---|
run_sql | Run a SQL statement on the application. | Yes |
disable | Disable the application. | No |
enable | Enable a disabled application. | No |
retry_upgrade | Retry upgrading the application. | No |
Prerequisites¶
Before you can use remote app operations, you need the following:
- Some remote app operations require the consumer to grant consent. See the consumer guide for more details.
- The hash value of the application. You can find this value in the APPLICATION_STATE view or by calling SYSTEM$GET_HASH_FOR_APPLICATION.
Operation type: run_sql¶
Consumer consent required? Yes.
To run a SQL statement on a Snowflake Native App, call the
SYSTEM$REMOTE_APP_OPERATION function
with the run_sql operation type. For example:
This function call executes SELECT * FROM app_schema.app_table as the application.
The system function returns a JSON string {"request_id": "<uuid>"}. This request_id can be used to query the result of the operation in the event table. See Querying operation results section below for more details.
Reading the result of the SQL statement¶
The execution of the SQL statement is logged in the event table, with information on the status, query result, and execution time. See the Querying operation results section below for more details.
Operation type: disable¶
Consumer consent required? No.
To disable a Snowflake Native App, call the
SYSTEM$REMOTE_APP_OPERATION function
with the disable operation type. For example:
The reason specified will be visible to the consumer as the application’s disablement reason, for instance in DESCRIBE APPLICATION.
The system function returns a JSON string {"request_id": "<uuid>"}. This request_id can be used to query the result of the operation in the event table. See Querying operation results section below for more details.
Operation type: enable¶
Consumer consent required? No.
To re-enable a Snowflake Native App that you previously disabled, call the
SYSTEM$REMOTE_APP_OPERATION function
with the enable operation type. For example:
Note
This operation can only enable applications that have been disabled by the provider. If an application was disabled by Snowflake, see What to do if an app is unavailable.
The system function returns a JSON string {"request_id": "<uuid>"}. This request_id can be used to query the result of the operation in the event table. See Querying operation results section below for more details.
Operation type: retry_upgrade¶
Consumer consent required? No.
To retry a failed upgrade on a Snowflake Native App, call the
SYSTEM$REMOTE_APP_OPERATION function
with the retry_upgrade operation type. This operation is non-blocking. For example:
The system function returns a JSON string {"request_id": "<uuid>"}. This request_id can be used to query the result of the operation in the event table. See Querying operation results section below for more details.
Querying operation results¶
Whenever SYSTEM$REMOTE_APP_OPERATION is called and modifies the consumer Snowflake Native App, the operation is logged in the event table for the consumer to view.
If event sharing is enabled, the provider can also query the operation results from the event table. Each successful SYSTEM$REMOTE_APP_OPERATION call returns a JSON string {"request_id": "<uuid>"}. Use this request_id to query the status and result of the operation in the event table.
Note
If SYSTEM$REMOTE_APP_OPERATION fails due to a syntax error or incorrect arguments (for example, the enable operation is called on an enabled application), the function call is not logged to the event table.
Here are example queries to get started: