Skip to content

Instantly share code, notes, and snippets.

@alexvanboxel
Created December 27, 2016 21:05
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 alexvanboxel/0acdc74465ef1a27878c8b70841cf24b to your computer and use it in GitHub Desktop.
Save alexvanboxel/0acdc74465ef1a27878c8b70841cf24b to your computer and use it in GitHub Desktop.
#standardSQL
SELECT
...,
station.lon AS station_longitude
FROM
`bigquery-public-data.noaa_gsod.gsod{{execution_date.year-8}}` AS gsob
JOIN
`bigquery-public-data.noaa_gsod.stations` AS station
ON
CAST(gsob.stn AS INT64)=station.usaf
AND CAST(gsob.wban AS INT64)=station.wban
WHERE
CAST(CONCAT(CAST((CAST(year AS INT64) + 8) AS STRING),'-',CAST(mo AS STRING),'-',CAST(da AS STRING)) AS DATE)
= '{{ ds }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment