Created
November 12, 2018 04:10
-
-
Save christinebuckler/d15406e9920d81b7ea801b37695fd688 to your computer and use it in GitHub Desktop.
Redshift - python UDF for decoding url strings
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
| -- This example decodes percent-encoded sequences from url parameters, | |
| -- replaces plus signs with spaces, and converts to all lowercase. | |
| CREATE OR REPLACE FUNCTION schema_name.function_name(original TEXT) | |
| RETURNS VARCHAR IMMUTABLE AS | |
| $$ | |
| import urllib | |
| u = urllib.unquote_plus(original) | |
| return u.lower() | |
| $$ | |
| LANGUAGE plpythonu; | |
| SELECT schema_name.function_name(original_url) | |
| FROM schema_name.table_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thanks for your sharing!