-
Notifications
You must be signed in to change notification settings - Fork 30
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
Doubling of escaped single quote for Snapshot generated SQL produces failed application #250
Comments
@dschoel-pr , that's because the temp_snapshot_relation_sql is wrapped up in a view . The view in Fabric DW is created using EXEC('create view ....'). A single quote needs to be replaced by two single quotes to execute the view correctly. Here is an example, I tested with and there seems to be no problem.
as dbt_scd_id, ;'); Can you share a repro with deps and commands you executed? If possible, share the logs file in the zip to validate your issue. |
Hi @prdpsvs , I am facing same issue. I have got the following query in the ephemeral linked to snapshot
The snapshot fails with the following error:
In dbt.log its generating the following code: ` EXEC('create view "dbo"."table_stock_snapshot_staging_temp_view" as with __dbt__cte__table_stock as ( select When I run this using Fabric Warehouse, it gives me the following error:
When I remove quotes from MD5 function, it works perfectly fine. @dschoel-pr where you able to find any solution for it ? Any help would be appreciated. |
I have also used hash function which is part of dbt-core, same error, double quotes creating issues. |
@prdpsvs Another example of the double quotes issue in snapshots. I created an incremental & snapshot with same code, snapshot view has errors, incremental doesn't.
This generates the following view:
Following is the code for snapshot:
& referenced ephemeral:
This generates the following code to create view:
As you can see above, snapshot code generation is creating so many quotes compared to incremental. Can you please prioritise this issue as its a major blocker for us. Regards, |
Running with dbt=1.8.8
Registered adapter: fabric=1.8.8
In a snapshot using dbt_utils.generate_surrogate_key, the snapshot execution fails with a SQL based error:
('42000', "[42000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Incorrect syntax near ''. (102) (SQLMoreResults)")
A debug level execution shows that the SQL produced to generate a staging temp view for the source data with double the amount of escaped single quotes:
EXEC('create view "silver"."mcp_InvoiceDetails__hist_snapshot_staging_temp_view" as
Some tracing shows that the following logic in the snapshot.sql macro, combined with downstream logic that packages the SQL into a string for EXEC are duplicating the attempt to add an escape single quote.
Tests show that removing the .replace on the top line allows the snapshot to function correctly.
Why is the replace in the logic? Can it be removed safely?
The text was updated successfully, but these errors were encountered: