Skip to content

Commit

Permalink
Add back in template fields for new operator (#61)
Browse files Browse the repository at this point in the history
* Add back in template fields for new operator

* Update version number so PR can be a release candidate as well.

* Add template fields unit test

* Add query_to_validate as a template field and .sql files as template extensions to allow sql files to be templated and passed into query_to_validate
  • Loading branch information
denimalpaca authored Nov 14, 2022
1 parent 577172b commit 1318b93
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## Upcoming
* (please add here)

## 0.2.1
* [BUGFIX] Add back in removed template fields

## 0.2.0
* [FEATURE] Enable the use of a default Checkpoint when a Checkpoint is not supplied, with the option to use the OpenLineage Validation Action
* [FEATURE] Add support to use Airflow connection information instead of separate Great Expectation Datasources.
Expand Down
10 changes: 9 additions & 1 deletion great_expectations_provider/operators/great_expectations.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@ class GreatExpectationsOperator(BaseOperator):

ui_color = "#AFEEEE"
ui_fgcolor = "#000000"

template_fields = (
"run_name",
"conn_id",
"data_context_root_dir",
"checkpoint_name",
"checkpoint_kwargs",
"query_to_validate"
)
template_ext = (".sql")
operator_extra_links = (GreatExpectationsDataDocsLink(),)

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="airflow-provider-great-expectations",
version="0.2.0",
version="0.2.1",
author="Great Expectations",
description="An Apache Airflow provider for Great Expectations",
entry_points="""
Expand Down
23 changes: 23 additions & 0 deletions tests/operators/test_great_expectations.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,29 @@ def configured_sql_operator(in_memory_data_context_config):
return operator


def test_great_expectations_operator__assert_template_fields_exist():
operator = GreatExpectationsOperator(
task_id="task_id",
data_context_root_dir=ge_root_dir,
checkpoint_name="taxi.pass.chk",
)
assert "run_name" in operator.template_fields
assert "conn_id" in operator.template_fields
assert "data_context_root_dir" in operator.template_fields
assert "checkpoint_name" in operator.template_fields
assert "checkpoint_kwargs" in operator.template_fields
assert "query_to_validate" in operator.template_fields


def test_great_expectations_operator__assert_template_ext_exist():
operator = GreatExpectationsOperator(
task_id="task_id",
data_context_root_dir=ge_root_dir,
checkpoint_name="taxi.pass.chk",
)
assert ".sql" in operator.template_ext


def test_great_expectations_operator__context_root_dir_and_checkpoint_name_pass():
operator = GreatExpectationsOperator(
task_id="task_id",
Expand Down

0 comments on commit 1318b93

Please sign in to comment.