Validating an application package¶
Prerequisites¶
You must have an existing connection in your
config.tomlfile.You must have a
snowflake.ymlfile in your Snowflake Native App project.
Snowflake CLI automatically validates a Snowflake Native App setup script, along with any other SQL files included using the SQL EXECUTE IMMEDIATE statement, when you run (snow app run) or deploy (snow app deploy) an application. It uses the script most recently uploaded by one of the commands. Validation checks for SQL syntax errors, invalid object references, and best practices. If the script validation fails, the executed command aborts but does not automatically roll back the staged files.
For more information about Snowflake Native App setup scripts, see Create the setup script in the Snowflake Native App Framework documentation.
How to validate a setup script manually¶
Occasionally, you might want to validate a setup script before deploying an application to avoid potential impacts that could occur if validation fails during the deployment process. The snow app validate command validates a setup script without needing to run or deploy an application. It uploads source files to a separate scratch stage that drops automatically after the command completes to avoid disturbing files in the application’s source stage.
Create a connection, if necessary.
Execute the
snow app validatecommand from within your project, similar to the following:When successful, the command returns the following message:
If validation fails, the following error message, along with any error messages, is displayed:
If you want to see the raw validation output as JSON, you can execute snow app validate --format json, as shown:
where:
errors shows a list of errors, if they exist. Errors cause validation to fail.
warnings shows a list of warnings, if they exist.
status shows the result of the validation: SUCCESS or FAILURE.
If validation encounters any errors, which cause validation to fail, or warnings, which lets is succeed, the command displays the following information for the error or warning:
message: Human-readable message for the error or warning.cause: Reason why the SQL construct is considered an error or warning.errorCode: Numeric code associated with the error or warning.fileName: Name of the file containing the error or warning, relative the stage root.line: Line number in the file identifying the location of the error or warning.column: Column number in the line where the error or warning occurred.
The following example shows a failed validation that contained both warnings and errors: