SQL Variables
When writing SQL in your Lightdash models, you can use the following references to template you SQL and make it more reusable
- ${field}- reference a field in the current model
- ${model.field}- reference a field in another model
- ${TABLE}- reference the current table's sql reference
- ${lightdash.attributes.my_attr_1}- a user attribute called- my_attr_1- (optional) ldas an alias forlightdash
- (optional) attributeorattras an alias forattributes
 
- (optional) 
- ${lightdash.user.<intrinsic_attribute>}- reference an- intrinsic_attributeof the current Lightdash user- (optional) ldas an alias forlightdash
- available intrinsic user attributes:- email
 
 
- (optional) 
info
The user email attribute is only available when the email is verified. This is a security measure to prevent users from creating/updating an account with any email they don't own and gain access to data they shouldn't see.
If the user email is not verified you will get the following error:
models:
  - name: example
    meta:
      sql_filter: ${lightdash.user.email} = 'example@lightdash.com'
If you are self hosting you can enable SMTP or SSO authentication to allow users to verify their email address.