-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ingest/snowflake): support email_as_user_identifier for queries v2
- Loading branch information
1 parent
73dce9e
commit a93fcf4
Showing
6 changed files
with
118 additions
and
40 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
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
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 |
---|---|---|
|
@@ -22,3 +22,49 @@ def test_source_close_cleans_tmp(snowflake_connect, tmp_path): | |
# This closes QueriesExtractor which in turn closes SqlParsingAggregator | ||
source.close() | ||
assert len(os.listdir(tmp_path)) == 0 | ||
|
||
|
||
@patch("snowflake.connector.connect") | ||
def test_user_identifiers_email_as_identifier(snowflake_connect, tmp_path): | ||
with patch("tempfile.tempdir", str(tmp_path)): | ||
source = SnowflakeQueriesSource.create( | ||
{ | ||
"connection": { | ||
"account_id": "ABC12345.ap-south-1.aws", | ||
"username": "TST_USR", | ||
"password": "TST_PWD", | ||
}, | ||
"email_as_user_identifier": True, | ||
"email_domain": "example.com", | ||
}, | ||
PipelineContext("run-id"), | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", "[email protected]") | ||
== "[email protected]" | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", None) | ||
== "[email protected]" | ||
) | ||
|
||
|
||
@patch("snowflake.connector.connect") | ||
def test_user_identifiers_username_as_identifier(snowflake_connect, tmp_path): | ||
with patch("tempfile.tempdir", str(tmp_path)): | ||
source = SnowflakeQueriesSource.create( | ||
{ | ||
"connection": { | ||
"account_id": "ABC12345.ap-south-1.aws", | ||
"username": "TST_USR", | ||
"password": "TST_PWD", | ||
}, | ||
"email_as_user_identifier": False, | ||
}, | ||
PipelineContext("run-id"), | ||
) | ||
assert ( | ||
source.identifiers.get_user_identifier("username", "[email protected]") | ||
== "username" | ||
) | ||
assert source.identifiers.get_user_identifier("username", None) == "username" |