问题
I made a bigquery table with one column named "row" (no quotes)... doh! Now my sql won't compile if I reference that column:
SELECT row, etext FROM [hcd.hdctext] LIMIT 1; =ERROR"
I did not see "ROW" as a reserved word in GQL...
I saw that in some systems you can get around that 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 reupload my 200M of data and start again. Seems like changing a field name would not be a big feature.. but I am naive about how the data is stored.
Thanks!
回答1:
BigQuery Legacy SQL uses []
as quote chars. BigQuery Standard SQL uses backticks.
So, for Legacy SQL, just use
SELECT [row], etext from [hcd.hdctext]
If you want to rename it permanently, there isn't a way to do that currently, but you can rename it in a query and save the results... just use
SELECT [row] as newname, .... FROM [hcd.hdctext]
and specify 'allow large results' and a destination table name.
回答2:
DOCS - CTRL-F "bracket" and it'll take you right to the paragraph in the docs.
This is multiple years late, but here is a link to the documentation for future reference, as per suggestion of Chris. I could not post it as a direct reply, but the question was marked answered long ago.
来源:https://stackoverflow.com/questions/18905842/oops-used-a-reserved-word-to-name-a-column