Handling table name changes
If the name of view’s base table changes in the database, it can cause content in Omni to break. Use thealiases parameter to add the table’s original name(s), which will allow Omni to find the correct table in the database.
Duplicating views with aliases
In some cases, you may need to duplicate a view - for example, ausers view that contains both buyers and sellers. Aliased views are automatically created when you define them as joins in the model’s Relationships file.
The following example demonstrates how to alias the users view to create buyers and sellers views. Note that the names of the aliased views are used to declare the joins:
relationships.yaml
Alias scope
An alias created byjoin_to_view_as or join_from_view_as only exists within:
- The
on_sqlof the relationship that creates it - The
joinsparameter of a topic, to bring the alias into that topic - Custom field or dimension SQL defined in the topic’s
viewsparameter, since that SQL is evaluated in the context of the topic where the alias is already joined in
Giving an alias its own fields, label, or display order
To customize an alias further — set itsdisplay_order or label in a topic, or add fields to it that other topic-level SQL can reference — extend the original view under the alias’s name instead of using join_to_view_as/join_from_view_as:
Topic file
buyers with join_to_view rather than aliasing users with join_to_view_as. Once buyers is declared this way it’s a real view: it can hold its own fields, take a display_order and label in the topic’s views parameter, and be used as a join target in other relationships — none of which a join_to_view_as/join_from_view_as alias supports.
Troubleshooting
Relationship alias duplicates view name / Table not found
Relationship alias duplicates view name / Table not found
This happens when a
join_to_view_as or join_from_view_as alias is declared in a topic’s views parameter without an extends parameter — Omni can’t resolve the alias as a table on its own.Add extends: [ <original_view> ] to the views entry, and change the relationship to join directly to the alias’s name with join_to_view (or join_from_view) instead of aliasing the original view. See Giving an alias its own fields, label, or display order above.View is not joined into topic
View is not joined into topic
This happens when a view file’s own field or dimension SQL references a
join_to_view_as/join_from_view_as alias (for example, ${my_alias.field}). View files are evaluated independently of any topic, so they have no way to know the alias will exist at query time.Move the field definition into the topic’s views parameter instead, under the alias’s name — SQL defined there can see aliases already joined into that topic.
