I'm using Google APIs Client Library for php, and I'd like to be able to validate a query before send it to execution. Are there any method in the Google BigQuery API to validate a query (Get the text in the red box).
I couldn't find it. I was reading this section https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
Select BigQuery under which you will find Scheduled queries option,click on that. In the filter tab you can enter the keywords and get the required query of the table.
BigQuery supports two types of queries: Interactive queries. Batch queries.
When you run a query in the bq command-line tool, you can use the --dry_run flag to estimate the number of bytes read by the query. You can also use the dryRun parameter when submitting a query job using the API or client libraries. Dry runs do not use query slots, and you are not charged for performing a dry run.
Setting the dryRun
parameter to true on a jobs.query
request should allow you to validate a query. Dry run queries don't catch all errors, but they can catch quite a few. The query validator in the web UI uses dry run queries to provide real-time errors as shown in your screenshot.
Docs for the dryRun
parameter:
[Optional] If set, don't actually run this job. A valid query will return a mostly empty response with some processing statistics, while an invalid query will return the same error it would if it wasn't a dry run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With