From 70a228f78b294d97358b46c2db0838c06c864b53 Mon Sep 17 00:00:00 2001 From: Vikrant Puppala Date: Sat, 23 May 2026 12:13:13 +0000 Subject: [PATCH] fix(utils): import ProgrammingError instead of bare `exc.` reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ParamEscaper.escape_args` and `ParamEscaper.escape_item` both raise `exc.ProgrammingError(...)` but `exc` was never imported into utils.py. On any unsupported parameter shape the user sees `NameError: name 'exc' is not defined` instead of a clean PEP-249 `ProgrammingError`, masking the actual problem. Surfaced via the python-comparator audit harness running the `INLINE_PARAMS` connection_config: both backends raised `NameError: name 'exc' is not defined`, which the comparator's class+message match treated as parity — a false-positive that hid both the real driver bug and the underlying caller-side type mismatch. Fix: import `ProgrammingError` directly from `databricks.sql.exc` (matching the pattern used in `session.py`, `client.py`, `result_set.py`, etc.) and replace the two `exc.ProgrammingError(...)` sites with bare `ProgrammingError(...)`. Signed-off-by: Vikrant Puppala --- src/databricks/sql/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/databricks/sql/utils.py b/src/databricks/sql/utils.py index 7ea0d7f5c..8682f0ad1 100644 --- a/src/databricks/sql/utils.py +++ b/src/databricks/sql/utils.py @@ -19,6 +19,7 @@ pyarrow = None from databricks.sql import OperationalError +from databricks.sql.exc import ProgrammingError from databricks.sql.cloudfetch.download_manager import ResultFileDownloadManager from databricks.sql.thrift_api.TCLIService.ttypes import ( TRowSet, @@ -548,7 +549,7 @@ def escape_args(self, parameters): elif isinstance(parameters, (list, tuple)): return tuple(self.escape_item(x) for x in parameters) else: - raise exc.ProgrammingError( + raise ProgrammingError( "Unsupported param format: {}".format(parameters) ) @@ -606,7 +607,7 @@ def escape_item(self, item): elif isinstance(item, Mapping): return self.escape_mapping(item) else: - raise exc.ProgrammingError("Unsupported object {}".format(item)) + raise ProgrammingError("Unsupported object {}".format(item)) def inject_parameters(operation: str, parameters: Dict[str, str]):