-
Notifications
You must be signed in to change notification settings - Fork 609
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
bug: Move from psycopg2
to psycopg
makes Redshift
unusable with ibis-framework
#10804
Comments
psycopg2
to psycopg
makes Redshift
unusable with ibis-framework
Thanks for the issue! We've heard reports from ... I can't remember exactly where that redshift works with Ibis, but glad to have a concrete statement about it somewhere.
For this error, can you provide a more detailed traceback? It might be possible to debug that without a redshift setup (probably wishful thinking!), but I would need the traceback. |
Hi @cpcloud and thank you for the prompt reply. t = rs_conn.table(name="table", database="prod.schema") Here is a more complete traceback: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "[REDACTED]/.venv2/lib/python3.12/site-packages/ibis/backends/sql/__init__.py", line 94, in table
table_schema = self.get_schema(name, catalog=catalog, database=database)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[REDACTED]/.venv2/lib/python3.12/site-packages/ibis/backends/postgres/__init__.py", line 514, in get_schema
with self._safe_raw_sql(type_info) as cur:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/python/3.12.6/lib/python3.12/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "[REDACTED]/.venv2/lib/python3.12/site-packages/ibis/backends/postgres/__init__.py", line 700, in _safe_raw_sql
with contextlib.closing(self.raw_sql(*args, **kwargs)) as result:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[REDACTED]/.venv2/lib/python3.12/site-packages/ibis/backends/postgres/__init__.py", line 717, in raw_sql
psycopg.types.TypeInfo.fetch(con, "hstore"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[REDACTED]/.venv2/lib/python3.12/site-packages/psycopg/_typeinfo.py", line 85, in fetch
return cls._fetch(conn, name)
^^^^^^^^^^^^^^^^^^^^^^
File "[REDACTED]/.venv2/lib/python3.12/site-packages/psycopg/_typeinfo.py", line 104, in _fetch
cur.execute(cls._get_info_query(conn), {"name": name})
File "[REDACTED]/.venv2/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
raise ex.with_traceback(None)
psycopg.errors.UndefinedColumn: column "typarray" does not exist in t Let me know if any further info would be useful. |
It looks like catching that exception is probably the way to go to unblock this very official redshift support. @galen-ft I will put up a PR that you should be able test against. |
Just tried PR#10805 and it does work around the immediate issue: t = rs_conn.table("table", database="prod.schema") # I get the warning you defined:
[REDACTED].venv2/lib/python3.12/site-packages/ibis/backends/postgres/__init__.py:730: UserWarning: Failed to load hstore extension: column "typarray" does not exist in t
warnings.warn(f"Failed to load hstore extension: {e}") and then the following works as expected: ibis.to_sql(t)
# SQLString('SELECT\n *\nFROM "prod"."schema"."table"') Could you please keep this issue open a little longer so that we can do some more testing?
|
Yes, this was intentional as part of addressing #9125. |
Yep, no worries! |
the issue happens here:
|
I'm going to merge the PR associated with this issue, but I'll leave this issue open until you say so @galen-ft! Thanks! |
Hi @cpcloud , thank you for being patient w.r.t. this issue. We are still writing a few more tests which we'd like to run against the Redshift backend. I will let you know once we're done. Also, happy to have the PR merged. |
What happened?
Hi ibis support team and thank you for this wonderful package ❤
I was looking for an alternative to R's dplyr + dbplyr for python and the ibis-framework is the best one I could find.
Issue description
I've been experimenting with the new features of
ibis-framework 10.0.0.dev490
(i.e. the addition ofcases()
and parameter distinct of thecollect()
method among others) and noticed that the move frompsycopg2
topsycopg
(3) introduces a regression which makesibis-framework
unusable with the Redshift backend. Please note thatibis-framework v9.5.0
, which usespsycopg2
, works well with Redshift.Potential solutions
From psycopg/psycopg#122 it isn't really clear when and if official Redshift support will be added to
psycopg
(3). Also, looking at #10659 it appears that the move away frompsycopg2
was not motivated by breaking changes. I do understand that there are of course other valid reasons for moving topsycopg
(3).Would it be possible to go back to
psycopg2
?Alternatively, is adding official Redshift support (via package
redshift-connector
or equivalent) on your project roadmap?Steps to reproduce the issue
Opening a connection to Redshift:
results in:
when execution reaches the Backend._post_connect() method.
I was able to get past the connection issue by using
client_encoding=UTF8
as suggested in psycopg/psycopg#122 like this:but then creating an ibis table
t = rs_conn.table(name="table", database="prod.schema")
using method Backend.raw_sql() hits a type incompatibility:What version of ibis are you using?
10.0.0.dev490
What backend(s) are you using, if any?
Redshift (through the ibis.postgres backend)
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: