Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bigquery: fail to change filed name

We are changing filed naming convention to UpperCamelCase. Then we realized that if it's a single-word name, BQ just ignore any case changes. For example, when we ran the following query, all field names changed as we expected, except that 'speed', 'ignition','latitude' and 'longitude' just remained as they were in lower case.... I wonder if it's a bug or with special consideration? It gave us a huge issue when we are migrating our big data in thousands of tables into new naming convention

     SELECT  
            file_date_time AS FileLastModifiedTime  
            ,driver_id AS DriverId  
            ,date_time AS DateTime  
            ,latitude AS Latitude  
            ,longitude AS Longitude  
            ,gps_valid AS  GpsValid  
            ,ignition AS Ignition  
            ,speed AS SPEED  
            ,gps_reason AS GpsReason  
            ,zip_code AS ZipCode  
      FROM MyTable
like image 515
foxwendy Avatar asked Feb 01 '26 21:02

foxwendy


1 Answers

This is a quirk in BQ's schema generation, for reasons mentioned in your other answer.

One workaround is to use a subselect that renames the fields to an intermediate name:

SELECT LatitudeTmp AS Latitude FROM
  (SELECT latitude AS LatitudeTmp FROM MyTable)
like image 181
Jeremy Condit Avatar answered Feb 04 '26 16:02

Jeremy Condit