title: Is it possible to pass an array to a prepared statement on Amazon Redshift?
body: <p>I need to pass an array to a prepared statement defined on AWS Redshift to filter my query. Since this is not supported in Redshift, I was trying to find a work around using a Python UDF. Something like:</p>
  
  <pre><code>-- a function to split a comma separated list of values (string is already validated)
  
  CREATE FUNCTION split_str_to_ints (string char) RETURNS int[] IMMUTABLE as $$
      def split_stoi(string):
        ints = [int(item) for item in string.split(',')]
        return ints
  $$ LANGUAGE plpythonu;
  </code></pre>
  
  <pre><code>-- a prepared statement to return orders filtered by company id
  
  PREPARE get_orders (char) as 
  SELECT order.id
         order.company_id,
         COUNT(order.id) AS order_count
  FROM order
    INNER JOIN company ON (order.company_id = company.company_id)
  WHERE company.company_id IN (split_str_to_ints($1))
  GROUP BY order.id, order.company_id
  ORDER BY order_count DESC;
  </code></pre>
  
  <pre><code>EXECUTE get_orders('1,2,3,4')
  </code></pre>
  
  <p>But when I want to define the function I get an error saying that array of integers is not a supported plpythonu UDF return type.</p>
  
  <p>Is there any way other way to pass list of integers (or chars) to a prepared statement on Redshift?</p>