Query API Result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 04:58 AM
Hi, I'm new here.
Currently I have to read information from a query in databricks. I've used the query API to get the query definition but so far I'm not able to run the query and get the results.
Is it possible? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 05:12 AM
When using the JobsAPI you need to specify dbutils.notebook.exit("returnValue") to pass the results once the notebook finished it's job (https://docs.databricks.com/notebooks/notebook-workflows.html#notebook-workflows-exit).
Then you can get notebook_output.result through the API (https://docs.databricks.com/dev-tools/api/latest/jobs.html#operation/JobsRunsGetOutput)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 05:27 AM
I'm actually using the '/2.0/preview/sql' endpoint.
I tried to use this one in the past but seems that the return has a limitation. Should I switch to the jobs API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 05:58 AM
It depends on what you're trying to do.
If you want to simply get a single value (or array of values) from the query - then jobsAPI is the way to go.
If you want to get the actualy query results as a table, then the best approach would be to save the results as a file on a storage.