Skip to content

Instantly share code, notes, and snippets.

@infinex
Created March 15, 2018 10:06
Show Gist options
  • Select an option

  • Save infinex/7507b8007c608e8443dfa66dd4fb71fb to your computer and use it in GitHub Desktop.

Select an option

Save infinex/7507b8007c608e8443dfa66dd4fb71fb to your computer and use it in GitHub Desktop.
bigquery stringify json
CREATE TEMP FUNCTION
cleanup(text
STRING
)
RETURNS
STRUCT <
key string,
value string>
LANGUAGE js AS """
return JSON.parse(text);
""";
with a as (SELECT "{\"value\": \"hello\",\"key\": \"bye\"}" as x)
select cleanup(x) from a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment