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

Can't detect hard-coded reference with - in name #417

Closed
1 of 6 tasks
simmartynas opened this issue Jan 29, 2024 · 2 comments
Closed
1 of 6 tasks

Can't detect hard-coded reference with - in name #417

simmartynas opened this issue Jan 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@simmartynas
Copy link
Contributor

Describe the bug

In BigQuery, table references can contain - in them. Test find_all_hard_coded_references.sql does not detect this because regex (\w+) does not include the hyphen (-) character.

Steps to reproduce

Sample model with hard-coded reference

SELECT
  *
FROM
  `project-name.dataset_name.table_name`

Expected results

09:17:43  19 of 25 FAIL 1 is_empty_fct_hard_coded_references_ ............................ [FAIL 1 in 0.82s]

Actual results

09:20:45  19 of 25 PASS is_empty_fct_hard_coded_references_ .............................. [PASS in 0.95s]

Screenshots and log output

This is after changing all regex from (\w+) to (\w+-?\w+) in find_all_hard_coded_reference.sql macro. Elswise, everything passes.
image

System information

packages:
  - package: dbt-labs/dbt_utils
    version: 1.1.1
  - package: dbt-labs/codegen
    version: 0.12.1
  - package: elementary-data/elementary
    version: 0.13.1
  - package: calogica/dbt_expectations
    version: 0.10.1
  - package: dbt-labs/dbt_project_evaluator
    version: 0.8.1

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • trino/starburst
  • other (specify: ____________)

The output of dbt --version:

Core:
  - installed: 1.7.5
  - latest:    1.7.6 - Update available!


Plugins:
  - bigquery: 1.7.3 - Up to date!
  - postgres: 1.6.1 - Not compatible!

Are you interested in contributing the fix?

Tested locally and replaced all regex from (\w+) to (\w+-?\w+) which makes - optional. After the change, test started detecting hard-coded references with hyphen (-) character. I don't know if this will affect something else, but in my case, it worked.

https://github.com/dbt-labs/dbt-project-evaluator/blob/main/macros/find_all_hard_coded_references.sql

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

hey @simmartynas! are you willing to open a PR with this change? I think it's a good one!

@b-per
Copy link
Collaborator

b-per commented May 13, 2024

Fix has been merged

@b-per b-per closed this as completed May 13, 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
Projects
None yet
Development

No branches or pull requests

3 participants