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

get_columns_in_relation() returns wrong columns for Temp Relations with the same relation identifier (table) as other schemas #293

Closed
visch opened this issue Sep 19, 2022 · 2 comments

Comments

@visch
Copy link

visch commented Sep 19, 2022

2022-09-15 17:57:11.594602 (Thread-4): On model.mart.DataMart__AzureAD__USERS: 
      SELECT
          column_name,
          data_type,
          character_maximum_length,
          numeric_precision,
          numeric_scale
      FROM
          (select
              ordinal_position,
              column_name,
              data_type,
              character_maximum_length,
              numeric_precision,
              numeric_scale
          from [DataMart].INFORMATION_SCHEMA.COLUMNS
          where table_name = '#USERS__dbt_tmp'
            and table_schema = 'AzureAD'
          UNION ALL
          select
              ordinal_position,
              column_name collate database_default,
              data_type collate database_default,
              character_maximum_length,
              numeric_precision,
              numeric_scale
          from tempdb.INFORMATION_SCHEMA.COLUMNS
          where table_name like '#USERS__dbt_tmp%') cols
      order by ordinal_position

This sql comes from https://github.com/dbt-msft/dbt-sqlserver/blob/master/dbt/include/sqlserver/macros/adapters/columns.sql#L27

My issue is that I have a schema AzrueAD with a table Users and another Schema with a table Users so I get columns from the wrong table in the relation.

@visch visch changed the title get_columns_in_relation() returns wrong columns for Models with the same relation identifier (table) as other schemas get_columns_in_relation() returns wrong columns for Temp Relations with the same relation identifier (table) as other schemas Sep 19, 2022
visch added a commit to visch/dbt-sqlserver that referenced this issue Sep 19, 2022
Had a case where I'm creating a temp table that conflicts with other temp tables that have the same name dbt-msft#293
@visch
Copy link
Author

visch commented Sep 19, 2022

Ended up being a threading issue as we have multiple queries with a "Users" identifier being run. Lots of potential fixes, easiest I thought was to just give the Temp table a unique name PR is in

@sdebruyn
Copy link
Member

fixed in #368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants