-
Notifications
You must be signed in to change notification settings - Fork 227
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
Add ConnectionWrapper base class #828
Conversation
@Fleid: This PR is ready to be merged |
@McKnight-42 : The CI's are failing unrelated to the code changes. We have seen that CI being flacky before. Could you investigate that? |
@JCZuurmond no worries i can rekick off the failing tests and I'll keep and eye on it. |
Looks like spark-session tests are failing due to:
Probably just a missing dependency in our spark image |
dbt/adapters/spark/connections.py
Outdated
@@ -154,7 +156,38 @@ def _connection_keys(self) -> Tuple[str, ...]: | |||
return "host", "port", "cluster", "endpoint", "schema", "organization" | |||
|
|||
|
|||
class PyhiveConnectionWrapper(object): | |||
class ConnectionWrapper(ABC): |
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 think I like this idea, but I have some questions. How does this class differ from BaseConnectionManager
in dbt-core
:
https://github.com/dbt-labs/dbt-core/blob/a1b067c683212bccd9bc10f6e52bcdd168ccf7ec/core/dbt/adapters/base/connections.py#L59
I know we already had PyhiveConnectionWrapper
; I'm not very familiar with that class, but it also seems specific to dbt-spark
. This interface looks very generic, like a set of minimal methods that any adapter would need to connect to something. Put another way, if we do need this class in addition to BaseConnectionManager
, perhaps we should put ConnectionWrapper
in dbt-core
and inherit from it here? Is there any reason to not do that?
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 think the ConnectionWrapper is pretty spark specific for the time being, @Fokko in case we want to add a generic connection wrapper in core in the future can we rename this class to: SparkConnectionWrapper
?
class ConnectionWrapper(ABC): | |
class SparkConnectionWrapper(ABC): |
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.
Thanks for the review! I agree with Colin, I think it is very Spark-specific, and I don't it doesn't add much value to move this to the core package. I've renamed the class 👍🏻
e80bc0f
to
c6033ec
Compare
dbt/adapters/spark/session.py
Outdated
@@ -9,6 +9,7 @@ | |||
from dbt.events import AdapterLogger | |||
from dbt.utils import DECIMALS | |||
from pyspark.sql import DataFrame, Row, SparkSession | |||
from dbt.spark.adapters import ConnectionWrapper |
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.
Wouldn't this line and it's reference below need to be updated? I'm surprised this passed tests; normally we'd import from dbt.adapters.spark
, and in this case dbt.adapters.spark.connections
since this class isn't in dbt.adapters.spark.__init__.py
.
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.
Probably because we have the spark session tests disabled
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.
Hmm, not sure how this happened, and also a bit scary that the linter didn't catch this.
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.
Need to cascade changes to ConnectionWrapper
to SessionConnectionWrapper
…add-base-class
6111157
to
38820c3
Compare
7e8b2fe
to
9a87646
Compare
@mikealfare @colin-rogers-dbt I think my PR was in a limbo state, I didn't correctly push my local changes because it was stuck in a merge. After fixing that, mypy was vocal again, and I had to push a few more changes. @JCZuurmond PTAL |
resolves #829
Description
Checklist
changie new
to create a changelog entry