Which table should i use for a range join hint?

Travis84
New Contributor II

I am a bit confused about how to use range join hints. Consider the following query

 

 
```
SELECT
  p.id,
  p.ts,
  p.value,
  rg.metric1,
  rg.metric2,
  rg.ts AS range_ts
FROM points p
LEFT JOIN LATERAL (
  SELECT r.metric1, r.metric2, r.ts
  FROM ranges r
  WHERE r.point_id = p.id
    AND r.ts BETWEEN p.ts - INTERVAL 1 MINUTE AND p.ts
  ORDER BY r.ts DESC
  LIMIT 1
) rg
```
should the hint be applies on points or on ranges?
does the hint go immediately after the first select statement?
 
In the documentation (Range join optimization | Databricks on AWS) the first example shows the hint applying to the points table, the 3rd example shows the hint applying to the ranges like table.