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

Convert SELECT statements from Teradata to BigQuery - Migration Guide

Here are the comparison between Teradata & BigQuery SQL SELECT versions:

TeradataBigQueryComments

SELECT
c
FROM
database.table

SELECT
c
FROM
project.dataset.table

Columns implicitly inferred from the table are supported

SELECT
table.c
FROM
database.table

SELECT
table.c
FROM
project.dataset.table

Using an explicit table reference is supported

SELECT
t.c
FROM
database.table t

SELECT
t.c
FROM
project.dataset.table t

Using an explicit table alias is supported

SELECT
t.c,count(1)
FROM
database.table t
group by 1

SELECT
t.c,count(1)
FROM
database.table t
group by 1

Using positional references in the group by clause is supported

SELECT
(subquery) AS flag,
CASE WHEN flag = 1 THEN ...

WITH flags AS (
subquery
),
SELECT
CASE WHEN flags.flag = 1 THEN ...

In BigQuery, columns cannot reference the output of other columns defined within the same select list. Prefer moving a subquery into a WITH clause
SELECT TOP 10 * FROM table 

SELECT * FROM table LIMIT 10 


Joins in Teradata vs BigQuery

TeradataBigQuery
FROM A, B ON A.id = B.id 
FROM A JOIN B ON A.id = B.id 

Using a comma between tables in Teradata is equal to an INNER JOIN, while in BigQuery it equals a CROSS JOIN (Cartesian product)