impl(bigquery): allow selecting jobs.insert for queries - #6508
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to route BigQuery queries through the jobs.insert API instead of the default jobs.query by adding a with_jobs_insert builder method to the Query struct. This is particularly useful when the full Job response is needed, such as for dry-run parameter discovery. The query execution logic has been updated to check this new flag, and several unit tests have been added to verify the behavior under different configurations. There are no review comments, and I have no feedback to provide as the changes are well-implemented and documented.
8da6be8 to
4f727d0
Compare
|
Hey @fornwall, thanks sending PRs. Maybe next time would be nice to file an issue to we can discuss first. I'm not on my computer right now to 100% confirm, but to get full job statistics, you just need to force Job creation, which can be controlled via the with_job_creation_mode(JobCreationMode::Required) (we default to Optional in our SDK). I'm not sure on the behavior with dry_run to be honest. We need to discuss more internally if we want to have a method to force jobs.insert vs jobs.query. |
jobs.query does not return job statistics, so queries that need them have to go through jobs.insert. Dry-run parameter discovery is one such case: the undeclared query parameters detected by a dry run are only reported in the job statistics. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
4f727d0 to
c495a5d
Compare
|
@alvarowolfx Thanks for the quick reply!
👍 Absolutely!
For dry runs no job is created (even with Forcing That is, AFAIK - happy to be informed if I'm wrong, or if there are other alternatives here :).
That's understandable! Should I do anything (close this PR and/or open an issue) while you discuss this internally? Btw, looked up what the java and python clients does here: |
Yeah, @fornwall you are correct, like I mentioned on the other PR, dry run queries was a totally blind spot on my implementation. I have been working on BQ SDK for the past years and never exercise that path that much (to be fair, BQ is huge). I worked a lot in Go and noticed that it's a problem on it too (we don't check the dry run flag to do routing, and queries are being routed to jobs.query there too https://github.com/googleapis/google-cloud-go/blob/f1e77ceda688f29544fe094f682a03515cb641a2/bigquery/query.go#L467). Another problem that I found here is that
If you don't mind, I'll open a PR superseding this one, because I think the best course of actions for now is to check for the dry_run parameter specifically and route to |
I don't mind at all! I'll close this one then
👍 Thanks yourself for the quick feedback and the information sharing! |
👍 That works for my current use cases at least, and sounds logical. |
Make it possible to force the
jobs.insertendpoint so dry runs can access statistics thatjobs.querydoes not return.