Base64 Decode in Redshift

Base64 Decode in Redshift

Is there a redshift/sql function to decode a base64 string ? If not please suggest me how to write a function in redshift to decode base64 ?

2

2 Answers

Thanks for the great suggestion. It worked. Here is my function. Only issue is that to create a function you have to be a superuser.

create function f_base64decode (a varchar)
  returns varchar
stable
as $$
  import base64
  return base64.b64decode(a)   
$$ language plpythonu;

We could check whether the programming language is trusted or not by querying the pg_language table. If it's not trusted, the lanpltrusted is FALSE

SELECT lanpltrusted 
FROM pg_language 
WHERE lanname LIKE 'plpythonu';

See this , You can create a function in Redshift, and you can use python to code it.

Here are some possible ways to do it in python Python base64 data decode

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.