dbt-project-evaluator
dbt-project-evaluator copied to clipboard
Comments are incorrectly flagged as hard coded references
Describe the bug
In some cases comments get flagged as hard coded references.
Steps to reproduce
In a comment, if a quoted string follows from
or join
it will be flagged as a hard coded reference.
-- from "a comment"
-- join "another comment"
-- from my_model
select
1
from
{{ ref('my_model') }}
The first two comment lines (with the quoted strings) get flagged, the third line does not.
Expected results
No hard coded references found.
Actual results
Both "a comment"
and "another comment"
get flagged as hard coded references.
Screenshots and log output
System information
The contents of your packages.yml
file:
Which database are you using dbt with?
- [ ] postgres
- [ ] redshift
- [ ] bigquery
- [x] snowflake
- [ ] trino/starburst
- [ ] other (specify: ____________)
The output of dbt --version
:
Core:
- installed: 1.7.3
- latest: 1.7.4 - Update available!
Your version of dbt-core is out of date!
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- snowflake: 1.7.1 - Up to date!
Additional context
Are you interested in contributing the fix?
Unfortunately I do not have time.
hey @deanmorin ! thanks for opening -- we can see if there's a straightforward way to skip commented lines. Can you help me understand why you might have from
or join
comments in your models?
@dave-connors-3 The actual comment that triggered this bug was describing what a particular CTE is for:
-- Find when the case first moves from "New" to any other status
We currently use commented-out SQL for our integration tests for hard-coded references, so if we were to make this change we'd need to rethink our tests for this package.
fct_model_6
:
{{
config(
materialized = 'table',
)
}}
select 1 as id
-- from {{ ref('stg_model_3') }}
-- union all
-- select
-- 3 as id
-- from my_db.my_schema.my_table
-- union all
-- select
-- 3 as id
-- from 'my_db'.'my_schema'.'my_table'
-- union all
-- select
-- 3 as id
-- from "my_db"."my_schema"."my_table"
-- union all
-- select
-- 3 as id
-- from `my_db`.`my_schema`.`my_table`
-- union all
-- select
-- 3 as id
-- from [my_db].[my_schema].[my_table]
-- union all
-- select
-- 4 as id
-- from my_schema.raw_relation_5
-- union all
-- select
-- 4 as id
-- from 'my_schema'.'raw_relation_5'
-- union all
-- select
-- 4 as id
-- from "my_schema"."raw_relation_5"
-- union all
-- select
-- 4 as id
-- from `my_schema`.`raw_relation_5`
-- union all
-- select
-- 4 as id
-- from [my_schema].[raw_relation_5]
-- union all
-- select
-- 4 as id
-- from `raw_relation_1`
-- union all
-- select
-- 4 as id
-- from "raw_relation_2"
-- union all
-- select
-- 4 as id
-- from [raw_relation_3]
-- union all
-- select
-- 4 as id
-- from 'raw_relation_4'
-- union all
-- select
-- 4 as id
-- from {{ var("my_table_reference") }}
-- union all
-- select
-- 4 as id
-- from {{ var('my_table_reference') }}
-- union all
-- select
-- 5 as id
-- from {{ var("my_table_reference", "table_d") }}
-- union all
-- select
-- 5 as id
-- from {{ var('my_table_reference', 'table_d') }}
-- select
-- 7 as id
-- from {{ var('my_table_reference', 'table_d') }}
This has been fixed recently See here.