My query is:
des_nn_query = '''SELECT eB.eboss_target_id, jds.coadd_object_id,
eB.ra as eboss_ra, eB.dec as eboss_dec, jds.ra as des_ra, jds.dec as des_dec,
jds.flux_auto_g, jds.flux_auto_r, jds.flux_auto_z,
(q3c_dist(eB.ra,eB.dec,jds.ra,jds.dec)*3600) as dist_arcsec
FROM mydb://eboss22_elg_v4 AS eB
INNER JOIN LATERAL (
SELECT ds.ra, ds.dec, ds.flux_auto_g, ds.flux_auto_r, ds.flux_auto_z
FROM
des_dr1.main AS ds
WHERE
q3c_join(eB.ra, eB.dec, ds.ra, ds.dec, 0.001388889)
ORDER BY q3c_dist(eB.ra, eB.dec, ds.ra, ds.dec)
ASC LIMIT 1
) as jds ON true;'''
which I run using the line:
des_nn_job = qc.query(sql = des_nn_query, out="mydb://eboss22_full_des_nn_xmatch")
The first time I ran it the second table 'des_dr1.main AS ds' was instead 'mydb://reduced_des_dr1_galaxies AS ds', and I didn't save the coadd_object_id, as I explained above.
It seems identical to your query, excepting of course the different columns saved and that I used an INNER JOIN to only keep the matched rows. Is there some additional step or clean up I'm missing?