Created
September 19, 2018 23:13
-
-
Save Sillson/d2f498e5629dc03df238d07ab7532dab to your computer and use it in GitHub Desktop.
capitalize function in bigquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
); | |
"""; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#Importante
make sure you
CASE
when there could be null values