-
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 (#12219)
- Loading branch information
1 parent
172736a
commit 3ca8d09
Showing
6 changed files
with
132 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,58 @@ 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): | ||
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]" | ||
) | ||
|
||
# We'd do best effort to use email as identifier, but would keep username as is, | ||
# if email can't be formed. | ||
source.identifiers.identifier_config.email_domain = None | ||
|
||
assert ( | ||
source.identifiers.get_user_identifier("username", "[email protected]") | ||
== "[email protected]" | ||
) | ||
|
||
assert source.identifiers.get_user_identifier("username", None) == "username" | ||
|
||
|
||
@patch("snowflake.connector.connect") | ||
def test_user_identifiers_username_as_identifier(snowflake_connect, 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" |