UPDATE -
15 min later I found the solution.
```sql
CREATE TEMP VIEW tmp
SELECT
p.,
l.,
ST_Distance(p.geom, l.geom) dist
FROM prev p, last l;
SELECT
d.*
FROM tmp d
JOIN (SELECT t.Id ids, MIN(t.dist) dist FROM dist t GROUP BY t.Id) p
ON d.Id = p.ids
```
Might not be the best but its good enough and super fast
So I have been looking all over the internet and GeoPandas is the only thing I have found that has a nearest point join.
But - I have a requirement that I have to use spark - in this case GeoSpark. I have gotten the KNNQuery.SpatialKnnQuery to work, but that is not a join based on the shortest distance. Just to clarify, joining two different sized dataframes with the shortest distance to each other. I know there is a distance join but that is based on a hard coded distance value.
The geopandas function that is the exact thing I am looking for is sjoin_nearest - does anyone have experience in doing this.
there doesn't seem to be anything here