Question

I'm trying to execute this:

  QueryRequest queryRequest = new QueryRequest().setQuery(query);
  Jobs jobs = getBigquery().jobs();
  Query queryResponse = jobs.query(PROJECT_ID, queryRequest);
  QueryResponse execute = queryResponse.execute();

How do I save the response to a table? Where do I set the destination table? While creating an insert job, I can set it in JobConfigurationQuery. How do I do this with a query job?

Was it helpful?

Solution

If you want to save results as a destination table, you need to use jobs.insert(). The jobs.query() method is just a shortcut, providing a limited set of functionality. Under the covers, jobs.query() does the exact same thing as jobs.insert().

If you are hitting concurrent job limitations with jobs.insert(), jobs.query() would have the exact same issue. That said, one way to avoid concurrent job errors is to use batch priority on your query job.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top