Skip to content

Commit 8a3f67a

Browse files
committed
Add DEBUG log on compile and verify insertmanyvalues path
- Adds a single DEBUG-level log in DatabricksStatementCompiler.__init__ recording the template and the compiled SQL. Fires once per compilation, only when sqlalchemy logging is at DEBUG. Quiet at default log levels — no per-bindparam noise. - Empirically verified the _deliver_insertmanyvalues_batches code path (compiler.py:5648) works with the backticked template. Flipping use_insertmanyvalues=True and bulk-inserting 20 rows into a table with a hyphenated column produced the expected SQL (:`id__0`, :`col-name__0`, ...) logged as "generated in X (insertmanyvalues)" by SQLAlchemy, and all 20 rows round-tripped. Co-authored-by: Isaac
1 parent fa99182 commit 8a3f67a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/databricks/sqlalchemy/_ddl.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ class DatabricksStatementCompiler(compiler.SQLCompiler):
120120
bindtemplate = property(lambda self: self._BIND_TEMPLATE, lambda self, _: None)
121121
compilation_bindtemplate = property(lambda self: self._BIND_TEMPLATE, lambda self, _: None)
122122

123+
def __init__(self, *args, **kwargs):
124+
super().__init__(*args, **kwargs)
125+
# One-line trace of what we rendered — helps debug reported SQL
126+
# issues without adding per-bindparam noise.
127+
if logger.isEnabledFor(logging.DEBUG):
128+
logger.debug(
129+
"DatabricksStatementCompiler compiled statement with "
130+
"backtick-quoted bind markers (template=%s): %s",
131+
self._BIND_TEMPLATE,
132+
self.string,
133+
)
134+
123135
def limit_clause(self, select, **kw):
124136
"""Identical to the default implementation of SQLCompiler.limit_clause except it writes LIMIT ALL instead of LIMIT -1,
125137
since Databricks SQL doesn't support the latter.

0 commit comments

Comments
 (0)