Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Field not found in BigQuery view

This might just be a bug in BQ, but maybe someone might be able to call me out on some error. Essentially what I'm trying to do is to add a field (say new_field) to a table and save that as a View to query later.

When I query the view, it throws an error about not being able to find the new_field.

Simplest way to replicate this error:

SELECT IF(corpus_date > 1599, "17th", "16th") AS century, *
FROM [publicdata:samples.shakespeare] 
WHERE corpus_date > 0;

Save As a view, call it bar.

SELECT * FROM [foo.bar]

will throw an error like:

Error: Field 'century' not found in table 'publicdata:samples.shakespeare'.

Any thoughts?

like image 928
Rohit Avatar asked Feb 03 '26 07:02

Rohit


1 Answers

Looks like there is an issue with * expansion in views. I've filed a bug and hopefully we'll be able to get a fix out soon. In the mean time, you should be able to work around the issue by adding all of the fields in the view explicitly.

For example if you save the view as the following:

SELECT IF(corpus_date > 1599, "17th", "16th") AS century, 
    word, word_count, corpus, corpus_date
FROM [publicdata:samples.shakespeare] 
WHERE corpus_date > 0;

then select * from [foo.view] will work.

like image 184
Jordan Tigani Avatar answered Feb 04 '26 23:02

Jordan Tigani