-
Notifications
You must be signed in to change notification settings - Fork 75
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
Expressions with aliased tables on right side of "is distinct from" operator in snowflake are incorrectly flagged as hard coded references. #338
Comments
hey @Qwertronix! great find! the logic for finding hard coded references live in this file -- I think we'd just need to adjust the regex to allow for this exception. Would you have interest in trying your hand at this change? |
Hmm, I could easily put together a PR with a "dirty" fix using a fixed-length negative lookbehind ( Capturing the general case with arbitrary whitespace seems orders of magnitude more complex (unless I'm missing some other way out) and might be easier to achieve with changes to the Jinja macro or perhaps as part of an implementation of #335. In terms of jinja macro options, that might mean adding a group of extra patterns to exclude, and running those patterns against each match to find matches output from the first list of patterns that match the "bad matches" filters from the second list of patterns, and filtering those out before passing the remaining matches to |
TIL that My 2 cents would be that a simple fixed-length negative lookbehind would be enough. I don't think that too many people would be using this syntax. |
previously gets flagged as hard-coded references. fixes dbt-labs#338
Hi @Qwertronix , I can see that you added changes in your fork. Would you want to raise a PR for that? In that case it would be great to add an integration tests that covers the issue that your changes are fixing. |
Hi @b-per! For sure, that was the reason for the hold-up -- I got pulled away by other tasks before I could finish writing integration tests and testing the fix itself. Can got kicked down the road for a few days, but I'm planning to get that finished up and submitted. |
Hi @Qwertronix - any update on this work? :) |
Yeah, ran into a bit of a blocker that made the simple naive approach I was going to take a bit of a non-starter. Obvious in hindsight. Can't negative-lookbehind both the "is distinct from" and "is not distinct from" at the same time in the same regex, so this needs a different solution than the one I was envisioning. Other business duties have taken priority in the meantime as usual :\ |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
I was able to reproduce by updating the SQL in
I attempted adding a negative look back for
Any ideas why this wouldn't work? |
I figured it out! I need to use the space |
Describe the bug
Expressions with aliased tables on right side of "is distinct from" operator (snowflake SQL) are incorrectly flagged as hard coded references. This only seems to occur when the right-side expression to the operator matches the pattern
table_alias.column_name
-- more complex expressions or column references without a table alias don't seem to trigger this eval.Steps to reproduce
Given this SQL in a model (using snowflake SQL for a project that only uses the snowflake adapter):
the last line flags this model under
fct_hard_coded_references
.Expected results
The evaluation should not flag
new.ALL_SOURCE_ATTRIBUTES
as a hard coded reference. The model should not get flagged in the case demonstrated above since there are no hard coded references in the snippet.Actual results
The model gets flagged, with
new.ALL_SOURCE_ATTRIBUTES
indicated as the hard_coded_reference that flagged this model.Screenshots and log output
System information
The contents of your
packages.yml
file:Which database are you using dbt with?
The output of
dbt --version
:Additional context
The code given in the example is not best practice, and the error can be circumvented with either a cross-database macro that implements similar functionality or with an exception, but even so it should not be flagged by this eval (maybe another eval should exist for similar scenarios).
Are you interested in contributing the fix?
Unsure where to start. Maybe, depending on current methodology used for finding hard coded references.
The text was updated successfully, but these errors were encountered: