Closed guaripete-github closed 1 year ago
Hi, thank you for reporting this issue.
This has also been reported as issue 114. Please see that issue for details of the proposed fix which has now been developed, and which will be included in the next release.
Fix released in v0.9.0. Let us know if you continue to have issues. Thanks!
Describe the bug Column names with parenthesis included in hashdiff are not properly escaped in the generated code.
Environment
dbt version: 1.1.1 dbtvault version: 0.8.3 Database/Platform: SQL Server
To Reproduce Steps to reproduce the behavior: Use a column name with parenthesis in hashdiff. The compiled code:
ISNULL(NULLIF(UPPER(TRIM(CAST(OPERATOR (REPORTED) AS VARCHAR(max)))), ''), '^^'),
Expected behavior The compiled code should be:
ISNULL(NULLIF(UPPER(TRIM(CAST("OPERATOR (REPORTED)" AS VARCHAR(max)))), ''), '^^'),
Additional context The issue seems to be in this logic in dbtvault/macros/supporting/hash.sql
dbtvault/macros/intenal/helpers/is_checks.sql
where a column with parenthesis in column name is considered an expression and uses the returned value of dbtvaul/macros/internal/metadata_processing/as_constant.sql
which again evaluates the column name as an expression, therefore not escaping it.
Bypassing the logic:
renders the expected code:
ISNULL(NULLIF(UPPER(TRIM(CAST("OPERATOR (REPORTED)" AS VARCHAR(max)))), ''), '^^'),
but not sure what could be the consequences of such.