Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find definition of user defined function in AWS Redshift

A co-worker at one point in time has defined a function in AWS Redshift. I have some doubts about its results and would like to see the code behind the function.

Is there any query I can do (or another method) that returns this code?

like image 658
PdevG Avatar asked Nov 02 '17 12:11

PdevG


People also ask

What is a user defined function in Amazon Redshift?

What are User Defined Functions? UDFs are scalar functions that can be customized and created from the Redshift data warehouse. Each function can accept a fixed number of arguments to return a single output. UDFs can be executed similarly to built in Redshift functions such as replace or lower .

Does Redshift support user defined functions?

You can create a custom scalar user-defined function (UDF) using either a SQL SELECT clause or a Python program. The new function is stored in the database and is available for any user with sufficient privileges to run. You run a custom scalar UDF in much the same way as you run existing Amazon Redshift functions.

What is a user defined function name?

User-defined functions are functions that you use to organize your code in the body of a policy. Once you define a function, you can call it in the same way as the built-in action and parser functions. Variables that are passed to a function are passed by reference, rather than by value.


1 Answers

Found the answer:

select * from pg_proc where proname ilike '%<function_name>%'

In the column: prosrc you can find the function definition. It seemed empty in SQLWorkbenchJ, but the code revealed itself after a double-click.

like image 53
PdevG Avatar answered Nov 08 '22 21:11

PdevG