-
Notifications
You must be signed in to change notification settings - Fork 598
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
feat(api): add disconnect method #8341
Conversation
Presuming by "in-process" you mean pandas/polars here and not |
da85415
to
c48d719
Compare
ibis/backends/tests/test_client.py
Outdated
with pytest.raises( | ||
( | ||
DuckDBConnectionException, | ||
ExaRuntimeError, | ||
MySQLInterfaceError, | ||
OracleInterfaceError, | ||
PsycoPg2InterfaceError, | ||
Py4JJavaError, | ||
PyDruidError, | ||
PyODBCProgrammingError, | ||
SnowflakeDatabaseError, | ||
sqlite3ProgrammingError, | ||
) | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know pytest.raises(Exception)
is considered evil, but writing all of these out is running afoul of our (good) test environment isolation. Hmmmmm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using pytest.raises(Exception)
seems fine to me honestly. We only care that things don't work, not necessarily why.
This adds a `disconnect` method to all backends. Previously we didn't do this since the actual connection was often wrapped in SQLAlchemy and our ability to terminate the connection was unclear. The DB-API spec states that there should be a `close` method, and that any subsequent operations on a given `Connection` should raise an error after `close` is called. This _mostly_ works. Trino, Clickhouse, Impala, and BigQuery do not conform to the DB-API in this way. They have the `close` method but don't raise when you make a subsequent call. For the in-process backends I've chosen to raise, since I don't think there's a clear meaning on what closing that connection would mean, but happy to take any suggestions there.
It disconnects too well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
We may want to follow up with the non-SQL backends to clear their table mappings for consistency with the notion that disconnecting cleans up ephemeral resources created during the session. That said, we can probably wait until someone asks for that!
## Description of changes This adds a `disconnect` method to all backends. Previously we didn't do this since the actual connection was often wrapped in SQLAlchemy and our ability to terminate the connection was unclear. The DB-API spec states that there should be a `close` method, and that any subsequent operations on a given `Connection` should raise an error after `close` is called. This _mostly_ works. Trino, Clickhouse, Impala, and BigQuery do not conform to the DB-API in this way. They have the `close` method but don't raise when you make a subsequent call. Spark is not a DB-API, but the `spark.sql.session.stop` method does the right thing. For the in-memory backends and Flink, this is a no-op as there is either nothing to disconnect or no exposed method to disconnect. ## Issues closed Resolves ibis-project#5940
Description of changes
This adds a
disconnect
method to all backends. Previously we didn't dothis since the actual connection was often wrapped in SQLAlchemy and our
ability to terminate the connection was unclear.
The DB-API spec states that there should be a
close
method, and thatany subsequent operations on a given
Connection
should raise an errorafter
close
is called.This mostly works.
Trino, Clickhouse, Impala, and BigQuery do not conform to the DB-API in
this way. They have the
close
method but don't raise when you make asubsequent call.
Spark is not a DB-API, but the
spark.sql.session.stop
method does the right thing.For the in-process backends I've chosen to raise, since I don't think
there's a clear meaning on what closing that connection would mean, but
happy to take any suggestions there.
Issues closed
Resolves #5940