dbt-core icon indicating copy to clipboard operation
dbt-core copied to clipboard

Adding metric expression validation

Open callum-mcdata opened this issue 2 years ago • 2 comments

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

callum-mcdata avatar Sep 16 '22 20:09 callum-mcdata

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.

github-actions[bot] avatar Sep 16 '22 20:09 github-actions[bot]

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?

callum-mcdata avatar Sep 16 '22 21:09 callum-mcdata

@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!

callum-mcdata avatar Sep 26 '22 16:09 callum-mcdata