diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e86328c6b5..97cc73b137f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features - Added macro get_partitions_metadata(table) to return partition metadata for partitioned table [#2596](https://github.com/fishtown-analytics/dbt/pull/2596) +- Added native python 're' module for regex in jinja templates [#2851](https://github.com/fishtown-analytics/dbt/pull/2851) ### Fixes - Respect --project-dir in dbt clean command ([#2840](https://github.com/fishtown-analytics/dbt/issues/2840), [#2841](https://github.com/fishtown-analytics/dbt/pull/2841)) @@ -9,6 +10,7 @@ Contributors: - [@feluelle](https://github.com/feluelle) ([#2841](https://github.com/fishtown-analytics/dbt/pull/2841)) - [ran-eh](https://github.com/ran-eh) [#2596](https://github.com/fishtown-analytics/dbt/pull/2596) +- [@hochoy](https://github.com/hochoy) [#2851](https://github.com/fishtown-analytics/dbt/pull/2851) ## dbt 0.19.0b1 (October 21, 2020) diff --git a/core/dbt/context/base.py b/core/dbt/context/base.py index 51d0ec44e73..f04ea33cb12 100644 --- a/core/dbt/context/base.py +++ b/core/dbt/context/base.py @@ -18,6 +18,7 @@ # approaches which will extend well to potentially many modules import pytz import datetime +import re def get_pytz_module_context() -> Dict[str, Any]: @@ -42,10 +43,19 @@ def get_datetime_module_context() -> Dict[str, Any]: } +def get_re_module_context() -> Dict[str, Any]: + context_exports = re.__all__ + + return { + name: getattr(re, name) for name in context_exports + } + + def get_context_modules() -> Dict[str, Dict[str, Any]]: return { 'pytz': get_pytz_module_context(), 'datetime': get_datetime_module_context(), + 're': get_re_module_context(), }