Skip to content

Commit

Permalink
ErrorResponse fix (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
perttus authored Dec 21, 2023
1 parent 70b1b51 commit 5a7f5e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ logs
*.egg-info
*__pycache__
*.pyc
.venv/
34 changes: 14 additions & 20 deletions dbt/adapters/vertica/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.




import os
import ssl
from contextlib import contextmanager
from dataclasses import dataclass
import ssl
import os
import requests
from typing import Optional
from dbt.contracts.connection import AdapterResponse
from typing import List, Optional, Tuple, Any, Iterable, Dict, Union
import dbt.clients.agate_helper
from typing import Any, List, Optional, Tuple, Union

import agate
import dbt.clients.agate_helper
import dbt.exceptions
import requests
import vertica_python
from dbt.adapters.base import Credentials
from dbt.adapters.sql import SQLConnectionManager
from dbt.events import AdapterLogger
logger = AdapterLogger("vertica")
from dbt.contracts.connection import AdapterResponse
from dbt.events import AdapterLogger


import dbt.exceptions
import vertica_python

logger = AdapterLogger("vertica")

@dataclass
class verticaCredentials(Credentials):
Expand Down Expand Up @@ -119,7 +113,7 @@ def open(cls, connection):
else:
context = ssl.create_default_context()
conn_info['ssl'] = context
logger.debug(f'SSL is on')
logger.debug('SSL is on')

def connect():
handle = vertica_python.connect(**conn_info)
Expand All @@ -146,7 +140,7 @@ def connect():
# used in dbt-integration-tests
if credentials.withMaterialization:
try:
logger.debug(f':P Set EnableWithClauseMaterialization')
logger.debug(':P Set EnableWithClauseMaterialization')
cur = connection.handle.cursor()
cur.execute("ALTER SESSION SET PARAMETER EnableWithClauseMaterialization=1")
cur.close()
Expand Down Expand Up @@ -200,7 +194,7 @@ def get_result_from_cursor(cls, cursor: Any, limit: Optional[int]) -> agate.Tabl
# check result for every query if there are some queries with ; separator
while cursor.nextset():
check = cursor._message
if isinstance(check, ErrorResponse):
if isinstance(check, vertica_python.vertica.messages.ErrorResponse):
logger.debug(f'Cursor message is: {check}')
self.release()
raise dbt.exceptions.DbtDatabaseError(str(check))
Expand Down Expand Up @@ -243,4 +237,4 @@ def exception_handler(self, sql):
@classmethod
def data_type_code_to_name(cls, type_code: Union[int, str]) -> str:
assert isinstance(type_code, int)
return vertica.connector.constants.FIELD_ID_TO_NAME[type_code]
return vertica_python.vertica.connector.constants.FIELD_ID_TO_NAME[type_code]

0 comments on commit 5a7f5e6

Please sign in to comment.