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

Comments are incorrectly flagged as hard coded references #409

Closed
1 of 6 tasks
deanmorin opened this issue Jan 2, 2024 · 4 comments
Closed
1 of 6 tasks

Comments are incorrectly flagged as hard coded references #409

deanmorin opened this issue Jan 2, 2024 · 4 comments
Labels
bug Something isn't working hard-coded refs

Comments

@deanmorin
Copy link

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
  • 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.

@deanmorin deanmorin added the bug Something isn't working label Jan 2, 2024
@dave-connors-3
Copy link
Collaborator

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?

@deanmorin
Copy link
Author

@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

@graciegoheen
Copy link
Collaborator

graciegoheen commented Jan 4, 2024

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') }}

@b-per
Copy link
Collaborator

b-per commented Apr 25, 2024

This has been fixed recently
See here.

@b-per b-per closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hard-coded refs
Projects
None yet
Development

No branches or pull requests

4 participants