Reputation: 601
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!
Upvotes: 17
Views: 21777
Reputation: 331
None of the above solutions work.
Use this:
SELECT * FROM TABLE a WHERE DATE(time) = "2022-07-07" and a.[RESERVED KEYWORD] = 'X'
Upvotes: 0
Reputation: 26617
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.
Upvotes: 26
Reputation: 73
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.
Upvotes: 1