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

Incremental update fails if the schema the the __dbt_temp differs from the base table #182

Closed
M4Al opened this issue May 24, 2024 · 2 comments

Comments

@M4Al
Copy link

M4Al commented May 24, 2024

I have a dbt model like this

WITH serviceEnteries AS (
    SELECT  
    case [PostingType] when 1 then 'Budget' when 2 then 'Actual' when 0 then 'Precalculation' end as PostingType
     ,OrderNo
    , SomeField

Now if in the incremental part are only records that result in 'Budget' lines, the schema of both tables will differ as can be seen here:
image

image

This is due to the fact how the Fabric Warehouse engine guesses data types.

dbt will then continue and try to sync these schema's by updating the PostType field from varchar(7) to varchar(14)
While it's technically possible it currently fails for some reason:

14:08:44  Changing col type from varchar(7) to varchar(14) in table database: "DWH"
schema: "silver_fin"
identifier: "ServiceEntry"

14:08:44  fabric adapter: Error running SQL: macro alter_column_type
14:08:44  fabric adapter: Rolling back transaction.
14:08:44  On model.mpl_dp.ServiceEntry: ROLLBACK
14:08:44  On model.mpl_dp.ServiceEntry: Close
14:08:44  Compilation Error in model ServiceEntry (models\silver\ServiceEntry.sql)
  'tmp_relation' is undefined

  > in macro alter_column_type (macros\adapters\columns.sql)
  > called by macro materialization_incremental_fabric (macros\materializations\models\incremental\incremental.sql)
  > called by model ServiceEntry (models\silver\ServiceEntry.sql)

I'm not sure why it fails to update the type.

@prdpsvs
Copy link
Collaborator

prdpsvs commented May 28, 2024

@M4Al , There is currently a bug in the adlter_column_type macro. I fixed this in 1.8.6 PR #178. I should release this soon.

@M4Al M4Al closed this as completed May 31, 2024
@M4Al
Copy link
Author

M4Al commented May 31, 2024

Fixed in 1.8.6

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

No branches or pull requests

2 participants