Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on ZetaSQL

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

ZetaSQL is a customized SQL dialect, along with parser and analyzer, that Google uses for products like BigQuery and Spanner.

unnest

cross join if an implicit join is used. Notice that cross join is equivalen to inner join in this case.

Left join can be used to keep rows which has a null/emtpry array.

some {
    proto {
        path 
            {
                repeated
                    {
                        field {
                            key: "key",
                            value: "value",
                        }
                    }
            }
    }
}
SELECT
  *,
  array(SELECT
    value 
  FROM
    UNNEST(some.proto.path.repated.field)
  WHERE 
    key = 'DESIRED_KEY') AS return_value,
FROM
  ads_signup_events_6
;

Comments