From 0d0c543607e04b6d44fd5e90b879a92ff88ecc71 Mon Sep 17 00:00:00 2001 From: Cor Zuurmond Date: Tue, 18 Jul 2023 18:12:16 +0200 Subject: [PATCH] Make server_side_parameters optional --- dbt/adapters/spark/connections.py | 4 +++- dbt/adapters/spark/session.py | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dbt/adapters/spark/connections.py b/dbt/adapters/spark/connections.py index 01e37b7c3..5d3e99a64 100644 --- a/dbt/adapters/spark/connections.py +++ b/dbt/adapters/spark/connections.py @@ -461,7 +461,9 @@ def open(cls, connection: Connection) -> Connection: SessionConnectionWrapper, ) - handle = SessionConnectionWrapper(Connection(creds.server_side_parameters)) + handle = SessionConnectionWrapper( + Connection(server_side_parameters=creds.server_side_parameters) + ) else: raise dbt.exceptions.DbtProfileError( f"invalid credential method: {creds.method}" diff --git a/dbt/adapters/spark/session.py b/dbt/adapters/spark/session.py index b7d0ade10..0e3717172 100644 --- a/dbt/adapters/spark/session.py +++ b/dbt/adapters/spark/session.py @@ -24,10 +24,10 @@ class Cursor: https://github.com/mkleehammer/pyodbc/wiki/Cursor """ - def __init__(self, server_side_parameters: Dict[str, Any]) -> None: + def __init__(self, *, server_side_parameters: Optional[Dict[str, Any]] = None) -> None: self._df: Optional[DataFrame] = None self._rows: Optional[List[Row]] = None - self.server_side_parameters = server_side_parameters + self.server_side_parameters = server_side_parameters or {} def __enter__(self) -> Cursor: return self @@ -165,8 +165,8 @@ class Connection: https://github.com/mkleehammer/pyodbc/wiki/Connection """ - def __init__(self, server_side_parameters: Dict[Any, str]) -> None: - self.server_side_parameters = server_side_parameters + def __init__(self, *, server_side_parameters: Optional[Dict[Any, str]] = None) -> None: + self.server_side_parameters = server_side_parameters or {} def cursor(self) -> Cursor: """ @@ -177,7 +177,7 @@ def cursor(self) -> Cursor: out : Cursor The cursor. """ - return Cursor(self.server_side_parameters) + return Cursor(server_side_parameters=self.server_side_parameters) class SessionConnectionWrapper(object):