dbt-labs / dbt-project-evaluator

This package contains macros and models to find DAG issues automatically
https://dbt-labs.github.io/dbt-project-evaluator/latest/
Apache License 2.0
447 stars 67 forks source link

*Multline* comments getting flagged with `fct_hard_coded_references` #476

Closed guyr-ziprecruiter closed 4 months ago

guyr-ziprecruiter commented 4 months ago

While fixed for ordinary comments:

https://github.com/dbt-labs/dbt-project-evaluator/blob/9f9c1db78e0382abb75a688a07a9196bf5fb171e/macros/find_all_hard_coded_references.sql#L17-L20

Mentioning table names inside multline comments

/*
my_database.my_table
*/

will result in a failure.

~For now I switched from multiline SQL comments to jinja2 comments (which are multiline by default)~

Switching the jinja2 multiline comments also does not cut it and gets flagged.

{#
my_database.my_table
#}

Fixing this could be nice 🙇 . Thanks!

b-per commented 4 months ago

I think this is where we reach the limits of what we can do with some already complex (but not insanely complex) regex.

I'd say that the best here is either to add the line comment in your multiline comment

/*
this is some comment
-- my_database.my_table
and this is some comment as well
*/

or use Jinja comments like you did

or convert your multi-line comments to multiple single-line ones


We could technically fix your specific use case, but I don't really want to then have to maintain it for all the combinations of multiline comments for every supported data warehouse