google-bigqueryouter-apply

I have a syntax error in my Outer Apply statement, I can't understand why


This is my code

SELECT
A.* ,
B.ID as CB_ID,

FROM 
    `TABLE_1` A

OUTER APPLY (
    SELECT TOP 1 
    FROM `TABLE_2` B
WHERE A.business_ID = B.company_ID)

I'm getting this error

Syntax error: Expected end of input but got keyword OUTER at [8:1]

and i dont understand why


Solution

  • I do not believe standard sql utilizes APPLYs. In this scenario you will have to switch to a LEFT OUTER join.

    The documentation here outlines the query syntax in BigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax