dbt-project-evaluator
dbt-project-evaluator copied to clipboard
Can't detect hard-coded reference with `-` in name
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.
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
- [x] 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
hey @simmartynas! are you willing to open a PR with this change? I think it's a good one!
Fix has been merged