calogica / dbt-expectations

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

[Feature Request]Add support for regex flags for BigQuery #252

Closed lookslikeitsnot closed 1 year ago

lookslikeitsnot commented 1 year ago

Is your feature request related to a problem? Please describe. For consistency sake since we already support flags for Postgres and Snowflake; and since the project description states it supports BigQuery, I believe it makes sense to add support for re2 flags in BigQuery regex matches .

Describe the solution you'd like Although BigQuery doesn't support flags as regex function parameters, it uses re2 and re2 supports flags by in-lining the flags (prepending the regex with (?flag)).

Additional context This is a follow-up on issue #245 that added support for flags in Postgres, Snowflake, and Redshift. The idea was briefly introduced here

lookslikeitsnot commented 1 year ago

Having flags as parameters for BigQuery instead of having them in the test pattern has a few advantages such as

  1. Easier flag validation
  2. Simpler adapter switching

However, it adds a few lines of code so it's going to be more work to maintain.

Note In the PR, adding flags both as parameters and in the test pattern doesn't cause execution errors. The flags in the pattern take precedence over the ones in the flag (which is expected flag behavior). e.g.: regex: (?i)[A-Z] (case-insensitive letter match) flags: -i (case-sensitive match) will be translated to (?-i)(?i)[A-Z] and match any lower- or upper-case character.

clausherther commented 1 year ago

Closed via #253