Unfortunately! uses a reserved word to denote a column

I made a bigquery table with one column named "row" (without quotes) ... doh! Now my sql will not compile if I refer to this column:

SELECT row, etext FROM [hcd.hdctext] LIMIT 1; =ERROR" 

I did not see "ROW" as a reserved word in GQL ...

I saw that on some systems you can get around this problem with backticks:

 SELECT `row`, etext FROM [hcd.hdctext] LIMIT 1; 

( Using reserved words in column names )

Any way to do the same in bigquery? Otherwise, I will have to restart my 200M data and start again. It seems that changing the field name will not be a big feature. But I'm naive about how data is stored.

Thanks!

+7
google-bigquery
source share
2 answers

BigQuery uses [] as quotation marks. so just use

 SELECT [row], etext from [hcd.hdctext] 

If you want to rename it forever, there is currently no way to do it, but you can rename it in the query and save the results ... just use

 SELECT [row] as newname, .... FROM [hcd.hdctext] 

and specify "allow large results" and the name of the destination table.

+8
source share

DOCS is the CTRL-F bracket, and this will lead you to the paragraph in the docs.

This is a few years later, but here is a link to the documentation for future use, as suggested by Chris . I could not publish it as a direct answer, but the question was noted a long time ago.

0
source share

All Articles