Awesome, thanks so much for the info and prompt response! Here's what seems 
to work. I'm sure we'll iterate as we se fit to clean things up a bit

https://github.com/influitive/blueshift/blob/master/lib/sequel/adapters/redshift.rb
https://github.com/influitive/blueshift/blob/master/lib/sequel/extensions/redshift_schema_dumper.rb



On Tuesday, March 8, 2016 at 5:29:15 PM UTC-5, Jeremy Evans wrote:
>
> On Tuesday, March 8, 2016 at 2:10:10 PM UTC-8, Brad Robertson wrote:
>>
>> We're using Redshift for business analytics with some modified code from 
>> the sequel-redshift  <https://github.com/remind101/sequel-redshift>gem. 
>> We're trying to write a schema dumper for it, but since Redshift is based 
>> on postgres 8, we get some weird errors dumping the schema:
>>
>> PG::WrongObjectType: ERROR:  op ANY/ALL (array) requires array on right 
>> side: SELECT "pg_attribute"."attname" AS "name", CAST("pg_attribute".
>> "atttypid" AS integer) AS "oid", CAST("basetype"."oid" AS integer) AS 
>> "base_oid", format_type("basetype"."oid", "pg_type"."typtypmod") AS 
>> "db_base_type", format_type("pg_type"."oid", "pg_attribute"."atttypmod") 
>> AS "db_type", pg_get_expr("pg_attrdef"."adbin", "pg_class"."oid") AS 
>> "default", NOT "pg_attribute"."attnotnull" AS "allow_null", COALESCE((
>> "pg_attribute"."attnum" = ANY("pg_index"."indkey")), false) AS 
>> "primary_key" FROM "pg_class" INNER JOIN "pg_attribute" ON (
>> "pg_attribute"."attrelid" = "pg_class"."oid") INNER JOIN "pg_type" ON (
>> "pg_type"."oid" = "pg_attribute"."atttypid") LEFT OUTER JOIN "pg_type" 
>> AS "basetype" ON ("basetype"."oid" = "pg_type"."typbasetype") LEFT OUTER 
>> JOIN "pg_attrdef" ON (("pg_attrdef"."adrelid" = "pg_class"."oid") AND (
>> "pg_attrdef"."adnum" = "pg_attribute"."attnum")) LEFT OUTER JOIN 
>> "pg_index" ON (("pg_index"."indrelid" = "pg_class"."oid") AND ("pg_index"
>> ."indisprimary" IS TRUE)) WHERE (("pg_attribute"."attisdropped" IS FALSE) 
>> AND ("pg_attribute"."attnum" > 0) AND ("pg_class"."oid" = CAST(CAST(
>> '"dummy"' AS regclass) AS oid))) ORDER BY "pg_attribute"."attnum"
>>
>>
>> I'm assuming Sequel no longer supports Postgres 8 which could be causing 
>> this syntax error, so I'm wondering if you can suggest the best approach to 
>> fixing this? Can we grab an old Postgres module from the Sequel codebase to 
>> use for Redshift specifically? What we're actually trying to achieve is an 
>> adapter that works for postgres (9.x) AND redshift because we ETL all our 
>> data into postgres, then do a dump to redshift for analytics. Is this 
>> possible? Or would we just have conflicts with old versions of 
>> Sequel/Postgres ?
>>
>
> You probably should just override the related method (schema_parse_table) 
> on Redshift so that it works correctly.  Sequel's PostgreSQL support 
> officially targets PostgreSQL 8.2+ (it requires INSERT RETURNING), but I 
> think Redshift forked pre-PostgreSQL 8.2.  In this case, it looks like 
> Redshift doesn't support the use of the ANY operator with int2vector types, 
> maybe they have to be cast to array, or a different approach has to be used.
>
> Note that similar issues probably occur in index parsing and foreign key 
> parsing, though those are less likely to affect ETL workloads.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to