Skip to content

Commit aed2a33

Browse files
author
Dilyan Marinov
committed
vdk-impala: handle decorate operation errors
Why? Due to logic in vdk-core, the managed cursor tries to execute all implementations of the db_connection_decoreate_operation hook. This happens even if it's not the correct cursor, e.g. an oracle cursor might try to execute impala queries. This case is handled in other plugins by wrapping the decorator in a try/catch block. However, the job should fail if the default db type is impala and the actual error is an impala error and not coming from some other cursor. What? Check the db_default_type config if an exception occurs in the decorator. If the db_default type is not impala, output an error log. If the db_default type is impala, re-throw the error How was this tested? Tested locally CI What kind of change is this? Bugfix Signed-off-by: Dilyan Marinov <mdilyan@vmware.com>
1 parent 356879d commit aed2a33

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

projects/vdk-plugins/vdk-impala/src/vdk/plugin/impala/impala_plugin.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def vdk_command_line(root_command: click.Group):
6666

6767
@hookimpl
6868
def initialize_job(self, context: JobContext) -> None:
69+
self._db_default_type = context.core_context.configuration.get_value(
70+
"DB_DEFAULT_TYPE"
71+
)
72+
6973
self._impala_cfg = ImpalaPluginConfiguration(
7074
context.core_context.configuration
7175
) # necessary for the query decoration hook
@@ -152,11 +156,25 @@ def db_connection_recover_operation(self, recovery_cursor: RecoveryCursor) -> No
152156
@hookimpl(tryfirst=True)
153157
def db_connection_decorate_operation(self, decoration_cursor: DecorationCursor):
154158
if self._impala_cfg.sync_ddl():
155-
decoration_cursor.execute("SET SYNC_DDL=True")
159+
try:
160+
decoration_cursor.execute("SET SYNC_DDL=True")
161+
except Exception as e:
162+
logging.getLogger(__name__).error(
163+
"Failed to execute 'SET SYNC_DDL=True'"
164+
)
165+
if self._db_default_type.lower() == "impala":
166+
raise e
156167
if self._impala_cfg.query_pool():
157-
decoration_cursor.execute(
158-
f"SET REQUEST_POOL='{self._impala_cfg.query_pool()}'"
159-
)
168+
try:
169+
decoration_cursor.execute(
170+
f"SET REQUEST_POOL='{self._impala_cfg.query_pool()}'"
171+
)
172+
except Exception as e:
173+
logging.getLogger(__name__).error(
174+
f"Failed to execute 'SET REQUEST_POOL='{self._impala_cfg.query_pool()}'"
175+
)
176+
if self._db_default_type.lower() == "impala":
177+
raise e
160178

161179

162180
@hookimpl

0 commit comments

Comments
 (0)