How to rename column in Big Query?
The "T" part of ETL is supported by means of SQL querying. You could either use directly query datastore backup as external table (https://cloud.google.com/bigquery/external-data-sources) or first load into temp table and then run SQL to transform it. Renaming in Standard SQL will look like following:
SELECT * EXCEPT(oldname1, oldname2), oldname1 as newname1, oldname2 as newname2 FROM ...
But since you mentioned name separated by dot: _key__.id
it is probably nested field with _key__
being of type RECORD, so the SQL will look like
SELECT * EXCEPT(_key__), _key__.id AS id FROM ...
Pratap Singh
I am a passionate full-stack engineer who love to code in the thick of technology esp. Web, mobile and cloud. Bit obsessed with quality and best practices in software development. A big fan of design patterns and architectural styles. I am always eager to learn new technologies and make an impact to the business I work for.
Updated on August 22, 2022Comments
-
Pratap Singh over 1 year
We are loading Datastore tables(i.e. kinds)(taken as backup in cloud storage) into Big Query manually. Is there any way to transform(rename etc.) datastore columns before being loaded to Big Query. It seems to support feature of E(extraction) and L(loading) but not T(transform) when datastore kind backups are loaded in Big Query. The problem is that we have column-key as a primary field in our datastore kinds and hence we see column with name- "_key__.id" when kind loaded into Big Query. We wanted this column to be loaded with name 'id' not "_key__.id". So just wondering, is there any way to rename the column in Big Query?
Timely help is hightly appreciated.