AcceptsSquare brackets containing a comma-separated list of view names
Special RulesYou must join a view to the
always_join forces one or more joins to be included in the SQL that Looker generates, even if the user has not selected a field from that joined view. Multiple joins can be required by using a comma-separated list like
[view_name_a, view_name_b, etc].
When Looker generates SQL for a query, it attempts to create the cleanest SQL possible, and will only use the joins that are necessary for the fields a user selects. By using
always_join, you can force joins to occur no matter what.
always_join may be valuable when a join is executed with the
type parameter, and the join is not a
LEFT JOIN. In such a situation the join may be critical to correctly limiting the rows that are returned.
Make sure that
member is always joined to
event, even if the user does not choose a field from
member. This limits the results to only look at member-generated events:
Make sure that
payment are always joined to
event, even if the user does not choose a field from either of those views. This limits the results to only look at member-generated events where the member has paid already:
A view must be joined to an Explore before it can be referenced in
If you want to place a view into
always_join, you need to make sure it is joined to the Explore where the
always_join is being used. For example, this will not work:
member view hasn’t been joined to
event, so it isn’t available for use in
Things to know
Don’t apply business logic in joins if possible
The standard Looker approach to joining is to use a
LEFT JOIN whenever possible. In the above examples, we avoid a
LEFT JOIN so that business logic can be applied within the join itself. For instance, in one of the examples we created an Explore that included only those events that were associated with members:
The preferred way to execute this in Looker would be to use a
LEFT JOIN to get event data and member data stuck together simply, like this:
Then you would create a dimension that you could set to yes or no, if you only wanted to look at member events, like this:
This approach is preferable because it gives users the flexibility to look at all events, or only member events, as they desire. You have not forced them to only look at member events via the join.