Skip to main content
This parameter is useful for setting database session properties or configurations that need to be applied before queries run, particularly when those configurations need to vary based on user-specific attributes. Supports all database dialects and Mustache syntax injection. If this parameter includes warehouse or session commands and other compute routing mechanisms - such as compute_routing - are defined in the model, Omni resolves them in a specific order. See Resolution precedence for more information.

Syntax

sql_preamble: <sql_statement>

Properties

sql_preamble
string
A SQL statement to execute as a setup query before running SQL statements in the connection. Supports Mustache syntax for dynamic value injection, such as user attributes via {{ omni_attributes.<attribute_name> }}. All dialects are supported.

Examples

Omni automatically quotes user attributes when files are saved in the model IDE, meaning that the attribute value is always treated as a string. For example, even if the value of {{ omni_attributes.special_prop_name }} is numeric - like 5 or 102 - it’ll be treated as if it were "5" or "102":
Set a database property using a custom user attribute
sql_preamble: SET some_database_prop = {{ omni_attributes.special_prop_name }}
If you’re using Snowflake or Databricks and you need to set a non-string property, you can use IDENTIFIER to convert the quoted string:
Snowflake and Databricks - Use IDENTIFIER to convert the attribute value type
sql_preamble: SET some_database_prop = IDENTIFIER({{ omni_attributes.special_prop_name }})