-
Notifications
You must be signed in to change notification settings - Fork 156
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
Redshift Reflection #195
Comments
I'll note that sqlalchemy==1.3.15 seems to work fine, so not sure about 1.3.11 causing this. |
Hmm, yes it does seem to work with 1.3.15 All I did in 1.3.16 to get the error was this
I believe it was this commit they added on Mar. 15th |
I'd be happy to review and integrate a PR to handle the behavior you're seeing in recent sqlalchemy versions. |
I'm fairly new to SQLAlchemy for Redshift, so still trying to wrap my head around how it works under the hood, but I can certainly TRY to figure it out and submit a PR |
For context, the maintainers here aren't actively doing new work on the project. We don't have bandwidth to do active maintenance or feature development, so we primarily are involved to vet contributions from the community. I appreciate you writing up the problem. Even if you're not able to get to a solution, it provides a good starting point if someone in the community is able to pick it up. |
Gotcha, that makes sense. I looked into what exactly generated columns are in Postgres and it seems like it's a new feature in Postgres 12 as of late 2019. I think it's safe to assume it isn't supported by Redshift and won't be for a long time, if ever, so it doesn't need to be implemented, but somehow ignored https://www.codeproject.com/Articles/5246207/Generated-Columns-in-PostgreSQL I'll take a crack at it this weekend |
The problem here is that sqlalchemy-redshift is overriding the private method
So @bshinnebarger, if you can't find a good way to resolve this without removing the dependence on a private method, it would be worth seeking support from SQLAlchemy directly in order to get to a safe implementation. |
@adblair Yes I did see we were doing that, but I did not try to fix that. I submitted a PR a couple weeks ago #197 where I updated the logic to mimic how SQLAlchemy was handling generated columns in a recent commit of theirs. Effectively it will gracefully ignore it, as this is a feature in PostgreSQL > 12 and Redshift is still around 8 and I don't think would support this feature anytime soon |
Dear friends, File: .../sqlalchemy_redshift/dialect.py", line 685, in _get_column_info **kw TypeError: _get_column_info() missing 1 required positional argument: 'generated' What should I do to put your software to work with 1.3.16? P.S. and these cyclical links to this topic on all the pages, promising a 'workaround' are particularly annoying if not to say very offensive. |
It looks like a change needs to happen in the following section of code:
In particular, the call to |
@alxfed I'm not a maintainer, just sharing what worked for me. At this very moment I'm using: SQLAlchemy 1.3.15 And everything works just fine when I do something like: The only thing I had to change was forcing SQLAlchemy to 1.3.15 Hope that helps until an official fix is in |
I just released 0.7.9 which includes #200 and should allow use of SQLAlchemy 1.3.16+. |
Greetings! It looks like this bug is not gone yet. The following condition is truthy for the SQLAlchemy versions 1.3.2-1.3.9: if sa.__version__ >= '1.3.16':
# SQLAlchemy 1.3.16 introduced generated columns,
# not supported in redshift
kw['generated'] = '' So it causes the following exception for these SQLAlchemy versions: TypeError: _get_column_info() got an unexpected keyword argument 'generated' The most simple solution is to convert version string representation to tuple of integers like this: version = tuple(int(x) for x in sa.__version__.split('.'))
if version >= (1, 2, 16):
kw['generated'] = '' But it may crash if version number is "1.4.0b1" for example (it is the current version of SQLAlchemy package on Github by the way). Maybe the packaging library can be used to compare versions but it means an extra dependency. |
Thanks for reporting, @GrayAn. Your explanation makes perfect sense. I agree that it would be desirable to do some "real" parsing of the version number here. |
I can make a pull request just don't know what is your current contribution policy. Is it OK to include |
I believe modern sqlalchemy versions require setuptools, which requires |
Noticed what I think is an issue similar to what was resolved in 0.7.1
https://sqlalchemy-redshift.readthedocs.io/en/latest/#id1
#138
Where reflection is failing in the same area due to support for generated columns being added in this change
https://docs.sqlalchemy.org/en/13/changelog/changelog_13.html#change-1.3.11
When I changed my environment to sqlalchemy==1.3.10 the issue went away, so I think I'm on the right track
The text was updated successfully, but these errors were encountered: