Knowledge Drop

BIGQUERY (HowTo): How do you escape a table or field name in BigQuery?

  • 15 June 2021
  • 0 replies
  • 1102 views

Userlevel 3
Badge

Last tested: Jan 10, 2018
 

In BQ Standard SQL, you can escape names by enclosing it in backticks:

SELECT `schema.table`.`field` AS table1.field FROM public.`schema.table` AS table1

 

In BQ Legacy SQL, you can escape names by enclosing it in brackets:

SELECT [schema.table.field] AS table1.field FROM [project:schema.table] AS table1

 

In Legacy SQL, this is only relevant if you have dashes in the name, which would cause an error without the brackets.

Source: BigQuery documentation

Chat tip: Escaping the table name this way in the sql_table_name parameter can resolve errors like Aliases referenced in the from clause must refer to preceding scans 

 

This content is subject to limited support.                

 

 

 


0 replies

Be the first to reply!

Reply