Skip to content

Instantly share code, notes, and snippets.

@shotleft
Last active December 25, 2019 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shotleft/df32104e9ec1d7a9f2e06c8135833e92 to your computer and use it in GitHub Desktop.
Save shotleft/df32104e9ec1d7a9f2e06c8135833e92 to your computer and use it in GitHub Desktop.
bq_nest10
WITH races AS (
SELECT "800M" AS race,
[STRUCT("Rudisha" as name, [23.4, 26.3, 26.4, 26.1] as splits),
STRUCT("Makhloufi" as name, [24.5, 25.4, 26.6, 26.1] as splits),
STRUCT("Murphy" as name, [23.9, 26.0, 27.0, 26.0] as splits),
STRUCT("Bosse" as name, [23.6, 26.2, 26.5, 27.1] as splits),
STRUCT("Rotich" as name, [24.7, 25.6, 26.9, 26.4] as splits),
STRUCT("Lewandowski" as name, [25.0, 25.7, 26.3, 27.2] as splits),
STRUCT("Kipketer" as name, [23.2, 26.1, 27.3, 29.4] as splits),
STRUCT("Berian" as name, [23.7, 26.1, 27.0, 29.3] as splits)]
AS participants)
SELECT
r.race,
participant.name,
splits
FROM races AS r
CROSS JOIN UNNEST(r.participants) as participant
CROSS JOIN UNNEST(participant.splits) AS splits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment