Skip to content

DDL emitted for integer primary keys isn't valid with Redshift #9

@sui66iy

Description

@sui66iy

Hi there,

If you run something like this code:

from sqlalchemy import create_engine, Table, Column, Integer, MetaData

def create_table(engine):

    tablename = 'temp_foo'
    id_col = Column('id', Integer, primary_key=True)
    value_col = Column('value', Integer)

    metadata = MetaData(bind=engine)

    table = Table(tablename, 
                  metadata, 
                  id_col, 
                  value_col,
                  prefixes=['TEMPORARY'])
    table.create(engine)

    return

You'll get an exception like this:

sqlalchemy.exc.NotSupportedError: (NotSupportedError) Column "temp_foo.id" has unsupported type "serial".
'\nCREATE TEMPORARY TABLE temp_foo (\n\tid SERIAL NOT NULL, \n\tvalue INTEGER, \n\tPRIMARY KEY (id)\n)\n\n' {}

I'm seeing this with sqlalchemy 0.8.3. I think your redshift dialect is inheriting the default Postgres/psycopg behavior, which doesn't work since SERIAL isn't a supported Redshift datatype.

It works fine if you use a Char or something for your primary key. (Or just create the table externally and simply refer to it.)

Thanks,

Mike

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions