dbt-core
dbt-core copied to clipboard
Adding metric expression validation
resolves #5871
Description
- changing default value for expression to None
- Adding test to confirm behavior
Checklist
- [X] I have read the contributing guide and understand what's expected of me
- [X] I have signed the CLA
- [X] I have run this code in development and it appears to resolve the stated issue
- [X] This PR includes tests, or tests are not required/relevant for this PR
- [ ] I have run
changie new
to create a changelog entry
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.
Interesting. I seem to be getting this error from the code quality check
error: Incompatible types in assignment (expression has type "None", variable has type "Union[str, int]") [assignment]
Is this method of implementation not correct? I suppose I could keep it the same and add another test under the validate
function but that feels like we'd be building too many patterns into the function instead of having it live in the spec itself?
@jtcohen6 I went with the second option and additionally removed the Union[str,int]
designation in UnparsedMetric
. It passed all of the tests that we have in dbt core and just to make sure I ran it through the test suite in dbt_metrics
as well. So assuming all the above tests complete we should be good to go!