This is not actually a Looker bug, but an oversight or, perhaps, a needed feature.
When misplacing sql
for sql_on
in a join condition (note: join type
is specified):
join: heap {
type: left_outer
relationship: one_to_one
sql: ${site_visits.id} = ${heap.user_id}
AND ${site_visits.type} = 'heap';;
}
The SQL generated will bypass the join:
FROM site_visits
site_visits.id = heap.user_id
AND site_visits.type = 'heap'
You might expect a validation alert from the New LookML, but since this is your typo under sql
value, there won’t be one.
Instead, you need to replace the sql
with a sql_on
join: heap {
type: left_outer
relationship: one_to_one
sql_on: ${site_visits.id} = ${heap.user_id}
AND ${site_visits.type} = 'heap';;
}
or alternatively, specify the join under sql
:
join: heap {
type: left_outer
relationship: one_to_one
sql: LEFT JOIN heap ON ${site_visits.id} = ${heap.user_id}
AND ${site_visits.type} = 'heap';;
}
Of course, Looker could be smarter to recognize that I have specified type: left_outer
join, which overlaps with a manual sql
LEFT JOIN. Ideally, it would warn me of a sql
keyword when type:
is already specified.