Skip to content

Commit

Permalink
#62: Fixed that ScriptsDeployer fails when it can't create the schema (
Browse files Browse the repository at this point in the history
  • Loading branch information
tkilias authored Oct 28, 2022
1 parent fef2504 commit de9ba9a
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 158 deletions.
3 changes: 3 additions & 0 deletions doc/changes/changes_0.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ TBD

### Features

n/a

### Bug Fixes

- #62: Fixed that ScriptsDeployer fails when it can't create the schema

### Refactoring

n/a

### Documentation

Expand Down
File renamed without changes.
13 changes: 8 additions & 5 deletions exasol_transformers_extension/deployment/scripts_deployer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pyexasol
from exasol_transformers_extension.deployment import constants, utils
import logging

logger = logging.getLogger(__name__)


Expand All @@ -13,11 +14,13 @@ def __init__(self, language_alias: str, schema: str,
logger.debug(f"Init {ScriptsDeployer.__name__}.")

def _open_schema(self) -> None:
queries = ["CREATE SCHEMA IF NOT EXISTS {schema_name}",
"OPEN SCHEMA {schema_name}"]
for query in queries:
self._pyexasol_conn.execute(query.format(schema_name=self._schema))
logger.debug(f"Schema {self._schema} is opened.")
try:
self._pyexasol_conn.execute(f"CREATE SCHEMA IF NOT EXISTS {self._schema}")
except pyexasol.ExaQueryError as e:
logger.warning(f"Could not create schema {self._schema}. Got error: {e}")
logger.info(f"Trying to open schema {self._schema} instead.")
self._pyexasol_conn.execute(f"OPEN SCHEMA {self._schema}")
logger.info(f"Schema {self._schema} is opened.")

def _deploy_udf_scripts(self) -> None:
for udf_call_src, template_src in constants.UDF_CALL_TEMPLATES.items():
Expand Down
Loading

0 comments on commit de9ba9a

Please sign in to comment.