Skip to main content
This parameter supports Mustache rendering, allowing you to dynamically inject values such as user attributes. 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. All dialects are supported.

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 }})