calogica / dbt-expectations

Port(ish) of Great Expectations to dbt test macros
https://calogica.github.io/dbt-expectations/
Apache License 2.0
1.04k stars 126 forks source link

Add option to escape raw strings in RegEx functions #191

Closed clausherther closed 1 year ago

clausherther commented 2 years ago

Closes #190

This PR adds functionality to allow the RegEx-based tests, such as expect_column_values_to_match_regex to accept unescaped/raw string patterns, by adding an optional is_raw parameter to the relevant tests. The default is False, i.e. regex strings are not automatically escaped.

For more context: BigQuery: uses r'...' to mark the string as "raw" Snowflake: uses $$..$$ to avoid needing escape characters (see https://docs.snowflake.com/en/sql-reference/functions-regexp.html#specifying-regular-expressions-in-dollar-quoted-string-constants)

clausherther commented 1 year ago

@adamcunnington-mlg would love your eyes on this when you get a chance. Thanks!

clausherther commented 1 year ago

@adamcunnington-mlg would love your eyes on this when you get a chance. Thanks!

I'm going to go ahead and merge this for the upcoming release, since it's a non-breaking change.