29 Jan 21 ·  Cpaul in Guides ·        Bookmark ·  Report ·  More actions.. Lock comments ·  Pin thread

Convert Column alias references from Teradata to BigQuery - Migration Guide

In a SELECT statement in Teradata, column aliases can be defined and referenced within the same query

SELECT
F AS flag,
CASE WHEN flag = 1 THEN 'Y' END AS COL2
FROM table

In BigQuery, Column alias references are not supported within the same query, instead you may want to form a subquery:

SELECT
q.*,
CASE WHEN q.flag = 1 THEN 'Y' END AS COL2
FROM (
SELECT
F AS flag
FROM table
) AS q

or if its a simple alias you can choose to use the column directly instead of the alias, like shown below

SELECT
F AS flag,
CASE WHEN F = 1 THEN 'Y' END AS COL2
FROM table

NOTE: The Roboquery converter currently doesn't handle the column alias resolution. It has to be done manually