Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change column comment with Alembic #191

eeshugerman opened this issue Feb 6, 2020 · 7 comments

Unable to change column comment with Alembic #191

eeshugerman opened this issue Feb 6, 2020 · 7 comments


Copy link

eeshugerman commented Feb 6, 2020

We're using sqlalchemy-redshift with Alembic, and have found that we are unable to add or change comments on columns. Creating a new column with a comment works fine though.

Let me know if there's any more information I can provide, or if I should open this issue with SQLAlchemy or Alembic.

from alembic import op

    comment='my column comment',
sqlalchemy.exc.CompileError: <class 'alembic.ddl.base.ColumnComment'> construct has no default compilation handler.
click for full traceback
Traceback (most recent call last):
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/", line 88, in _compiler_dispatch
    meth = getter(visitor)
AttributeError: 'RedshiftDDLCompiler' object has no attribute 'visit_clause'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/", line 423, in _wrap_existing_dispatch
    return existing_dispatch(element, compiler, **kw)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/", line 90, in _compiler_dispatch
    raise exc.UnsupportedCompilationError(visitor, cls)
sqlalchemy.exc.UnsupportedCompilationError: Compiler <sqlalchemy_redshift.dialect.RedshiftDDLCompiler object at 0x7f2436379a20> can't render element of type <class 'sqlalchemy.sql.elements.ClauseElement'> (Background on this error at:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elliott/.virtualenvs/dwp/bin/alembic", line 10, in <module>
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/", line 573, in main
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/", line 567, in main
    self.run_cmd(cfg, options)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/", line 547, in run_cmd
    **dict((k, getattr(options, k, None)) for k in kwarg)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/", line 298, in upgrade
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/script/", line 489, in run_env
    util.load_python_file(self.dir, "")
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/util/", line 98, in load_python_file
    module = load_module_py(module_id, path)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/util/", line 173, in load_module_py
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "alembic/", line 152, in <module>
  File "alembic/", line 146, in run_migrations_online
  File "<string>", line 8, in run_migrations
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/runtime/", line 846, in run_migrations
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/runtime/", line 518, in run_migrations
  File "/home/elliott/dwp/arthur/ltbd/alembic/versions/", line 24, in upgrade
    comment="test comment",
  File "<string>", line 8, in alter_column
  File "<string>", line 3, in alter_column
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/operations/", line 1777, in alter_column
    return operations.invoke(alt)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/operations/", line 345, in invoke
    return fn(self, operation)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/operations/", line 56, in alter_column
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/ddl/", line 140, in alter_column
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/ddl/", line 212, in alter_column
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/ddl/", line 134, in _exec
    return conn.execute(construct, *multiparams, **params)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/engine/", line 988, in execute
    return meth(self, multiparams, params)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/", line 72, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/engine/", line 1043, in _execute_ddl
    else None,
  File "<string>", line 1, in <lambda>
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/", line 462, in compile
    return self._compiler(dialect, bind=bind, **kw)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/", line 29, in _compiler
    return dialect.ddl_compiler(dialect, self, **kw)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/", line 319, in __init__
    self.string = self.process(self.statement, **compile_kwargs)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/", line 350, in process
    return obj._compiler_dispatch(self, **kwargs)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/", line 436, in <lambda>
    lambda *arg, **kw: existing(*arg, **kw),
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/", line 478, in __call__
    return fn(element, compiler, **kw)
  File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/", line 427, in _wrap_existing_dispatch
    "compilation handler." % type(element)
sqlalchemy.exc.CompileError: <class 'alembic.ddl.base.ColumnComment'> construct has no default compilation handler.
Copy link

jklukas commented Feb 7, 2020

I don't know whether this is a problem at the SQLAlchemy level, Alembic level, or with this dialect.

Neither of the maintainers (me and @graingert) are active users of the project anymore, so we aren't likely to be able to spend time investigating further. If you're able to identify the problem, though, a PR would be welcome and I'll try to prioritize reviewing and merging.

Copy link
Contributor Author

@zzzeek, any insight?

Copy link

zzzeek commented Feb 7, 2020

sure, you need to add the ColumnComment element in the same way RenameTable is supported here: . I see a few other PG-specific elements that may or may not apply to redshift as well.

    from alembic.ddl.base import ColumnComment
    compiles(ColumnComment, 'redshift')(postgresql.visit_column_comment)

@jklukas is sqlalchemy-redshift still maintained?

Copy link

jklukas commented Feb 7, 2020

@jklukas is sqlalchemy-redshift still maintained?

It's mostly just me at this point and I am not actively making improvements. I review and merge PRs and make new releases, but I'm not investing any time in directing the project or anticipating new needs.

Probably the right thing to do at this point is to advertise for new maintainers and see if there is anybody willing to be more active.

Copy link
Contributor Author

Thanks @zzzeek! @jklukas I'll open a PR when I have a chance.

Copy link
Contributor Author

Finally had a chance to come back to this. PR: #198

Copy link

jklukas commented May 5, 2020

Merged. Thanks for putting this together, @eeshugerman

@jklukas jklukas closed this as completed May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants