Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to debug sqlparam issues with seeds #249

Closed
jtcohen6 opened this issue Nov 8, 2021 · 0 comments · Fixed by #250
Closed

Make it easier to debug sqlparam issues with seeds #249

jtcohen6 opened this issue Nov 8, 2021 · 0 comments · Fixed by #250
Labels
enhancement New feature or request

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented Nov 8, 2021

dbt uses SQL parameters when inserting static data into seeds. The most common SQL parameter is %s, but pyodbc uses ? instead. Today, we achieve that switch at the very last moment, right when dbt is going to execute the SQL:

# pyodbc only supports `qmark` sql params!
query = sqlparams.SQLParams('format', 'qmark')
sql, bindings = query.format(sql, bindings)
self._cursor.execute(sql, *bindings)

This is tricky, though, because it means that the SQL logged to logs/dbt.log appears to contain the incorrect SQL parameters. I'd much rather have it be the correct one, if possible, to aid in debugging what dbt actually ran.

We refactored the seed materialization for v0.21, and kicked get_binding_char() into its own macro. I think this means that we could:

  • reimplement spark__get_binding_char to return %s or ? based on target.method == 'odbc'
  • reimplement spark__load_csv_rows to look more like default__load_csv_rows
  • do we still need a custom seed materialization at all?
@jtcohen6 jtcohen6 added the enhancement New feature or request label Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant