Skip to content
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

fix: add correct import for exceptions #440

Merged
merged 4 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
- Change GlueColumn parent from base Column to SparkColumn
- Fix unraised DbtDatabaseError
- Fix get_columns_in_relation function to stop returning additional partition columns

- Fix exceptions import for FailedToConnectError and ExecutableError

## v1.8.1
- Fix typo in README.md
- Fix unit test failure caused by moto 5 upgrade
Expand Down
12 changes: 7 additions & 5 deletions dbt/adapters/glue/gluedbapi/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import uuid
from dbt.adapters.events.logging import AdapterLogger

logger = AdapterLogger("Glue")
from dbt.adapters.exceptions.connection import FailedToConnectError
from dbt_common.exceptions import ExecutableError

logger = AdapterLogger("Glue")

class GlueSessionState:
READY = "READY"
Expand Down Expand Up @@ -141,11 +143,11 @@ def _connect(self) -> None:
except WaiterError as we:
# If it comes here, creation failed, do not re-try (loop)
logger.exception(f'Connect failed to setup a session for {self.session_id}')
raise dbterrors.FailedToConnectError(str(we))
raise FailedToConnectError(str(we))
except Exception as e:
# If it comes here, creation failed, do not re-try (loop)
logger.exception(f'Error during connect for session {self.session_id}')
raise dbterrors.FailedToConnectError(str(e))
raise FailedToConnectError(str(e))

def _create_session(
self,
Expand Down Expand Up @@ -226,7 +228,7 @@ def _init_session(self):
statement.execute()
except Exception as e:
logger.error(f"Error in GlueCursor (session_id={self.session_id}, SQLPROXY) execute: {e}")
raise dbterrors.ExecutableError(str(e))
raise ExecutableError(str(e))

statement = GlueStatement(client=self.client, session_id=self.session_id,
code=f"spark.sql('use {self.credentials.database}')")
Expand All @@ -235,7 +237,7 @@ def _init_session(self):
statement.execute()
except Exception as e:
logger.error(f"Error in GlueCursor (session_id={self.session_id}, SQLPROXY) execute: {e}")
raise dbterrors.ExecutableError(str(e))
raise ExecutableError(str(e))

@property
def session_id(self):
Expand Down
Loading