Models
Models are references to a database connection. They serve as the data model's reference to the warehouses itself. That connection to the database is referenced by the model's connection
property, which references the name
property of the credentials specified in the Zenlytic interface.
Models, like all files in Zenlytic, are YAML text files.
#
PropertiesModels only have a few core properties:
type
: (Required) The type of the file. For these model files is should always be model
.
name
: (Required) The name of the model. If you reference this model elsewhere this is the name you will use. Like all names, it follows Zenlytic naming conventions
label
: The label of the model is what shows up to the end users of your data model. If not specified it defaults to the name of the model.
connection
: (Required) This is the name of the database connection that is being referenced in Zenlytic. You will specify this name when you enter the database credentials in Zenlytic, and it follows Zenlytic's conventions for names
week_start_day
: This controls which day of the week Zenlytic assumes your definition of "Week" starts on. The default value is monday
(which is standard across ISO dates).
timezone
: This controls which timezone Zenlytic uses when querying dates and times from your database. Zenlytic will automatically change the timezone from the database timezone to the timezone you set here. The default is to make no change to the timezone found in the database.
default_convert_tz
: This field sets the default value for convert_tz
in each dimension group in this model. This defaults to true
so if you set a timezone, it will be applied, unless you either set this value to false
or set convert_tz: false
on the field itself.
access_grants
: This field is a list of access grants. You can use access grants to control what data users of Zenlytic are allowed to see and access.
#
ExamplesHere is an example of a model that also sets a timezone for all queries to the database.
version: 1type: modelname: my_modelconnection: my_connectiontimezone: America/New_York
This is an example of an access grant defined in a model. In this case, this access grant could be reused in a view or in fields to limit viewing to only users who have the their department
user attribute equal to "Marketing". This model also sets the week_start_day
property which tells which day to start weeks on (the default is monday).
version: 1type: modelname: demoweek_start_day: sunday
# This defines the access grantaccess_grants: - name: restrict_dept user_attribute: department allowed_values: ["Marketing"]