Skip to content

Conversation

@darkclouder
Copy link

@darkclouder darkclouder commented Nov 19, 2025

Problem

column_name_to_quoted is set inside {%- if not column_name_to_data_types -%}.
When column_name_to_data_types is not falsy, this variable is not set.
I.e. whenever anything truthy for column_name_to_data_types is passed, this macro will always lead to a compilation error.

I'm currently working on a PR for dbt-core where get_fixture_sql gets passed a dictionary for column_name_to_data_types. So far column_name_to_data_types is always passed as None.

Solution

Defining a var inside an if statement and using it afterwards outside is generally a bad practice.
I decided to use adapter.quote instead of what comes back from adapter.get_columns_in_relation, so this should always work, independent from if the if case exists or not.
Thanks to that we don't even need the variable column_name_to_quoted.
Feel free to add any comments and suggestions on what's better to use than adapter.quote.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@darkclouder darkclouder requested a review from a team as a code owner November 19, 2025 13:40
@cla-bot
Copy link

cla-bot bot commented Nov 19, 2025

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @darkclouder

@darkclouder darkclouder force-pushed the fix-get_fixture_sql-with-types branch from 7634b79 to b3f9ecb Compare November 19, 2025 13:43
@cla-bot
Copy link

cla-bot bot commented Nov 19, 2025

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @darkclouder

@darkclouder darkclouder marked this pull request as draft November 19, 2025 13:43
@darkclouder darkclouder force-pushed the fix-get_fixture_sql-with-types branch from b3f9ecb to befe527 Compare November 19, 2025 14:03
@cla-bot cla-bot bot added the cla:yes The PR author has signed the CLA label Nov 19, 2025
@darkclouder darkclouder marked this pull request as ready for review November 19, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes The PR author has signed the CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant