runt18 / google-bigquery

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

BigQuery TABLE_DATE_RANGE support for schema updates #439

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Let's say I have a table set that is partitioned by day in BigQuery.
Prior to 2015-01-13 it looked like: 
sales_20150112 
( OrderId, 
Field_1, 
Field_2, 
... 
... 
Field_10 
) 

on 2015-01-13 new field added: Field_11, and it now looks like: 

sales_20150113 
( OrderId, 
Field_1, 
Field_2, 
... 
... 
Field_10, 
Field_11 
) 

When executing query 1: 
select OrderId, Field_1, Field_2, Field_10 from TABLE_DATE_RANGE(sales_, 
TIMESTAMP('2015-01-12'), TIMESTAMP('2015-01-13') 
BigQuery is able to produce a result. 

When executing query 2: 
select OrderId, Field_1, Field_2, Field_10, Field_11 from 
TABLE_DATE_RANGE(sales_, TIMESTAMP('2015-01-12'), TIMESTAMP('2015-01-13') 
BigQuery throws an error that reads like: "Field_11" does not exists in 
sales_20150112

I would like it to return null for fields that aren't present rather than 
throwing an error, as while I could use inner SELECTS and JOIN clauses, this is 
not an ideal workaround for the following reasons:
1) It requires prior analysis on the schema to see where/when new field is 
present which is not always feasible depending on the size of the range
2) Many programs execute dynamic code, as is my case, and creating additional 
logic can cause other issues.
3) It requires end users to have fairly advanced SQL skills, which is not 
always available.

By instead automatically putting a null in for those fields in rows where it 
would not apply (such as would be included in the results with a FULL OUTER 
JOIN), this makes updating the schema easier without requiring a complete 
overhaul of query logic.

Original issue reported on code.google.com by mkev...@google.com on 10 Feb 2016 at 1:20

GoogleCodeExporter commented 8 years ago
This is an oft-requested feature, and good news: the code was checked in a few 
days ago. It's buried pretty deep in the stack, so it may be a few weeks before 
it goes live.

Original comment by jcon...@google.com on 10 Feb 2016 at 5:08

GoogleCodeExporter commented 8 years ago
Awesome! Can't wait!

Original comment by domo...@gmail.com on 10 Feb 2016 at 4:53