-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add schema parameter and data_asset_name parsing (#75)
* Add schema parameter and data_asset_name parsing A new schema parameter will overwrite the supplied connection's schema, if it exists. If a data_asset_name is provided in the form 'schema.table', the schema will be parsed out into self.schema and data_asset_name will be updated to only be the table. This will also override the supplied schema in the connection. * Fix new test name * Update great_expectations_provider/operators/great_expectations.py Co-authored-by: Kaxil Naik <[email protected]> * Remove conn param as it was a test from a different branch. Co-authored-by: Kaxil Naik <[email protected]>
- Loading branch information
1 parent
981f586
commit 21bdf99
Showing
2 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -862,6 +862,69 @@ def test_great_expectations_operator__make_connection_string_sqlite(): | |
assert operator.make_connection_string() == test_conn_str | ||
|
||
|
||
def test_great_expectations_operator__make_connection_string_schema_parameter(): | ||
test_conn_str = ( | ||
"snowflake://user:[email protected]/database/test_schema_parameter?warehouse=warehouse&role=role" | ||
) | ||
operator = GreatExpectationsOperator( | ||
task_id="task_id", | ||
data_context_config=in_memory_data_context_config, | ||
data_asset_name="test_schema.test_table", | ||
conn_id="snowflake_default", | ||
expectation_suite_name="suite", | ||
schema="test_schema_parameter", | ||
) | ||
operator.conn = Connection( | ||
conn_id="snowflake_default", | ||
conn_type="snowflake", | ||
host="connection", | ||
login="user", | ||
password="password", | ||
schema="schema", | ||
port=5439, | ||
extra={ | ||
"extra__snowflake__role": "role", | ||
"extra__snowflake__warehouse": "warehouse", | ||
"extra__snowflake__database": "database", | ||
"extra__snowflake__region": "region-east-1", | ||
"extra__snowflake__account": "account", | ||
}, | ||
) | ||
operator.conn_type = operator.conn.conn_type | ||
assert operator.make_connection_string() == test_conn_str | ||
|
||
|
||
def test_great_expectations_operator__make_connection_string_data_asset_name_schema_parse(): | ||
test_conn_str = ( | ||
"snowflake://user:[email protected]/database/test_schema?warehouse=warehouse&role=role" | ||
) | ||
operator = GreatExpectationsOperator( | ||
task_id="task_id", | ||
data_context_config=in_memory_data_context_config, | ||
data_asset_name="test_schema.test_table", | ||
conn_id="snowflake_default", | ||
expectation_suite_name="suite", | ||
) | ||
operator.conn = Connection( | ||
conn_id="snowflake_default", | ||
conn_type="snowflake", | ||
host="connection", | ||
login="user", | ||
password="password", | ||
port=5439, | ||
extra={ | ||
"extra__snowflake__role": "role", | ||
"extra__snowflake__warehouse": "warehouse", | ||
"extra__snowflake__database": "database", | ||
"extra__snowflake__region": "region-east-1", | ||
"extra__snowflake__account": "account", | ||
}, | ||
) | ||
operator.conn_type = operator.conn.conn_type | ||
assert operator.make_connection_string() == test_conn_str | ||
assert operator.data_asset_name == "test_table" | ||
|
||
|
||
def test_great_expectations_operator__make_connection_string_raise_error(): | ||
operator = GreatExpectationsOperator( | ||
task_id="task_id", | ||
|