RAISE
Important Notice: Migration of Documentation Website
Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:
Official Snowflake Snowconvert Documentation
For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].
Thank you for your understanding.
Description
Use the
RAISE levelstatement to report messages and raise errors.
RAISE are fully supported by Snowflake.
Grammar Syntax
RAISE level 'format' [, variable [, ...]];In Amazon Redshift, the RAISE statement is used to generate messages in the console or throw custom exceptions. Redshift allows you to specify different levels to indicate the severity of the message. In Snowflake, this functionality can be emulated using a user-defined function (UDF) that makes a call to the console depending on the specified level.
Exception: When the level is "EXCEPTION", a custom exception is raised with a general message: "To view the EXCEPTION MESSAGE, you need to check the log." The exception code is
-20002, which informs the user that the custom message can be found in the logs. This is due to limitations when sending custom exceptions in Snowflake.Warning: If the level is "WARNING",
SYSTEM$LOG_WARNis used to print the warning message to Snowflake's log, which helps highlight potential issues without interrupting the flow of execution.Info: For any other level (such as "INFO"),
SYSTEM$LOG_INFOis used to print the message to the console log, providing more detailed feedback about the system's state without causing critical disruptions.
This approach allows emulating Redshift's severity levels functionality, adapting them to Snowflake’s syntax and features, while maintaining flexibility and control over the messages and exceptions generated during execution.
Limitations
To view logs in Snowflake, it is necessary to have specific privileges, such as the
ACCOUNTADMINorSECURITYADMINroles.Logs in Snowflake are not available immediately and may have a slight delay before the information is visible.
Personalized error messages in exceptions are not displayed like in Redshift. To view custom messages, you must access the logs directly.
For further information, please refer to the following page.
Sample Source Patterns
Input Code:
Output Code:
UDFs
Known Issues
There are no known issues.
Related EWIs.
There are no related EWIs.
Last updated
