Skip to main content

When to use this

Different data sources follow different naming conventions. A CRM might return ContactFirstName, an advertising platform might use campaign-id, and a database export might use TOTAL AMT. Before joining or analyzing data from multiple sources, renaming columns to a consistent convention (typically snake_case) makes everything easier to work with downstream.

Sample input

A hubspot_contacts table in the Raw layer with mixed naming conventions:
ContactIdFirstNameLastNameemailAddressPhone Number
101AliceJohnsonalice@acme.com+1-555-0101
102BobSmithbob@globex.com+1-555-0102
103CarolLeecarol@initech.com+1-555-0103
We want to rename all columns to snake_case:

Implementation

BigQuery also uses column aliases. Use backticks for columns with spaces or special characters.
SELECT
  ContactId      AS contact_id,
  FirstName      AS first_name,
  LastName       AS last_name,
  emailAddress   AS email_address,
  `Phone Number` AS phone_number
FROM `raw.hubspot_contacts`
BigQuery is case-insensitive for column names by default, but using explicit aliases ensures consistent naming for BI tools and downstream consumers.

Expected output

contact_idfirst_namelast_nameemail_addressphone_number
101AliceJohnsonalice@acme.com+1-555-0101
102BobSmithbob@globex.com+1-555-0102
103CarolLeecarol@initech.com+1-555-0103

Tips and gotchas

Renaming columns doesn’t change the underlying data — it only affects how the column is referenced in the output. Always save the renamed table to a new layer (e.g., Trusted) so the raw data remains untouched.
Some BI tools are case-sensitive when referencing column names. Sticking to snake_case with all lowercase avoids surprises when connecting Looker Studio, Power BI, or Metabase to your data.