Skip to content

Commit d75c32f

Browse files
committed
fix: Align DuckDB with qmark fixes
1 parent 74ae4ec commit d75c32f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

deepnote_toolkit/sql/sql_execution.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ class ExecuteSqlError(Exception):
160160
}
161161
param_style = dialect_param_styles.get(url_obj.drivername)
162162

163+
if requires_duckdb and param_style is None:
164+
# DuckDB uses the DB-API qmark style (`?` placeholders)
165+
param_style = "qmark"
166+
163167
skip_template_render = re.search(
164168
"^snowflake.*host=.*.proxy.cloud.getdbt.com", sql_alchemy_dict["url"]
165169
)
@@ -294,10 +298,7 @@ def _execute_sql_with_caching(
294298
):
295299
# duckdb SQL is not cached, so we can skip the logic below for duckdb
296300
if requires_duckdb:
297-
# duckdb requires % to be unescaped, but other dialects require it to be escaped as %%
298-
# https://docs.sqlalchemy.org/en/14/faq/sqlexpressions.html#why-are-percent-signs-being-doubled-up-when-stringifying-sql-statements
299-
query_unescaped = query % () if query else query
300-
dataframe = execute_duckdb_sql(query_unescaped, bind_params)
301+
dataframe = execute_duckdb_sql(query, bind_params)
301302
# for Chained SQL we return the dataframe with the SQL source attached as DeepnoteQueryPreview object
302303
if return_variable_type == "query_preview":
303304
return _convert_dataframe_to_query_preview(dataframe, query_preview_source)

0 commit comments

Comments
 (0)