0 votes
1 view
I am trying to match a sample of quasars (4200 objects) to DESI DR1 with the following query;

SELECT a.*, b.flux_r, b.flux_ivar_r, b.flux_z, b.flux_ivar_z
FROM mydb://desi_highz AS a, desi_dr1.photometry AS b
WHERE q3c_join(a.ra, a.declination, b.ra, b.dec, 1./3600.);

The query executes without error and displays the first 100 rows of the table, however, when I try to save the output to mydb I get an error and when I try to download the table as a .csv I get a load of junk. If I open the error message in the jobs tab I don't get anything meaningful - does anyone have any ideas?
ago by mstepney (120 points) | 1 view

1 Answer

0 votes

I assume you are using the query interface on our Data Explorer page? If so, that interface uses ADQL, and mydb:// tables cannot be aliased in ADQL (the "FROM mydb://desi_highz AS a" part of your query). Instead, I would recommend using our Jupyter notebook server and submitting the query in SQL like:

from dl import queryClient as qc

q = """
SELECT a.*, b.flux_r, b.flux_ivar_r, b.flux_z, b.flux_ivar_z

FROM mydb://desi_highz AS a, desi_dr1.photometry AS b
WHERE q3c_join(a.ra, a.declination, b.ra, b.dec, 1./3600.)
"""

res = qc.query(sql=q, out='mydb://desi_highz_results')

Or if you want to download the table as a .csv file:

res = qc.query(sql=q, out='./desi_highz_results.csv')

ago by ajacques (1.5k points)
FIXED: I needed to authClient.login() before accessing mydb

Thank you - I was using the Data Explorer. When I navigate to "Launch notebook" and try the above I get the following error: "queryClientError: Error: QM: MyDB table desi_highz does not exist'". I uploaded it to mydb on the data explorer page, is there an additional step required to get access to the database in the Jupyter lab?
Oh yes sorry I forgot to include that in my original reply but yep you got it, you need to be logged in with authClient first

521 questions

529 answers

511 comments

699 users

Welcome to Data Lab Help Desk, where you can ask questions and receive answers from other members of the community.

Categories