Im trying to extract an array using array_position
to return the position of a specific string. Unfortunately, redshift doesn’t have this function.
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
To solve this problem, I have created a python UDF.
Code sample:
Hope, this will help someone to simulate the
array_position
function in RedShift.You will need to unroll / unnest / unpivot the array and apply a WHERE clause. See: https://docs.aws.amazon.com/redshift/latest/dg/query-super.html#unnest
Using an UDF as you propose will function file for small number of rows but Redshift tables often have very large tables and UDF do not perform well on large row counts. Calling a UDF millions of times just is too much overhead. So watch for scaling issues.