Skip to content

Instantly share code, notes, and snippets.

@Sillson
Created September 19, 2018 23:13
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 Sillson/d2f498e5629dc03df238d07ab7532dab to your computer and use it in GitHub Desktop.
Save Sillson/d2f498e5629dc03df238d07ab7532dab to your computer and use it in GitHub Desktop.
capitalize function in bigquery
CREATE TEMPORARY FUNCTION capitalize(str STRING)
RETURNS STRING
LANGUAGE js AS """
return str.replace(
/\\w\\S*/g,
function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}
);
""";
@Sillson
Copy link
Author

Sillson commented Sep 19, 2018

#Importante
make sure you CASE when there could be null values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment