sijocherian / google-bigquery

Automatically exported from code.google.com/p/google-bigquery
0 stars 0 forks source link

Ability to get output schema before executing a query #251

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Say I want to do a SELECT query into a new destination table. Is there a way to 
know the output table schema before executing it?

This could be useful when for mapping query results to type-safe objects in 
Hadoop/Dataflow jobs.

Original issue reported on code.google.com by nevi...@spotify.com on 22 May 2015 at 6:36

GoogleCodeExporter commented 9 years ago
Unfortunately, it's not possible right now, but we'd like to add this to the 
output of a "dryRun" query.

A short-term workaround is to create a view with that query, and inspect the 
view's schema.

Original comment by jcon...@google.com on 22 May 2015 at 6:39

GoogleCodeExporter commented 9 years ago
Thanks, that'd be great.
What's the difference of view vs. destination table here, cost & performance 
wise?

Original comment by nevi...@spotify.com on 22 May 2015 at 6:41

GoogleCodeExporter commented 9 years ago
Well, I'm not suggesting using views in place of a destination table. Instead, 
I'm suggesting that you use the view's ability to compute a query's output 
schema as a hacky way of getting the info you want.

If you're about to run a query Q and want to know the output schema, create a 
temporary view with query Q (via tables.insert), inspect the schema on the 
resulting view object, and then delete the view. Voila!

There's no cost to create or delete a view.

Original comment by jcon...@google.com on 22 May 2015 at 6:50