mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-16 12:38:13 +00:00
ingest(snowflake): remove email_as_user_identifier support (#13827)
This commit is contained in:
parent
b3a25d6fbd
commit
f8c6db07d8
@ -154,14 +154,11 @@ class SnowflakeIdentifierConfig(
|
|||||||
|
|
||||||
email_domain: Optional[str] = pydantic.Field(
|
email_domain: Optional[str] = pydantic.Field(
|
||||||
default=None,
|
default=None,
|
||||||
description="Email domain of your organization so users can be displayed on UI appropriately.",
|
description="Email domain of your organization so users can be displayed on UI appropriately. This is used only if we cannot infer email ID.",
|
||||||
)
|
)
|
||||||
|
|
||||||
email_as_user_identifier: bool = Field(
|
_email_as_user_identifier = pydantic_removed_field(
|
||||||
default=True,
|
"email_as_user_identifier",
|
||||||
description="Format user urns as an email, if the snowflake user's email is set. If `email_domain` is "
|
|
||||||
"provided, generates email addresses for snowflake users with unset emails, based on their "
|
|
||||||
"username.",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -325,15 +325,10 @@ class SnowflakeIdentifierBuilder:
|
|||||||
user_email: Optional[str],
|
user_email: Optional[str],
|
||||||
) -> str:
|
) -> str:
|
||||||
if user_email:
|
if user_email:
|
||||||
return self.snowflake_identifier(
|
return self.snowflake_identifier(user_email)
|
||||||
user_email
|
|
||||||
if self.identifier_config.email_as_user_identifier is True
|
|
||||||
else user_email.split("@")[0]
|
|
||||||
)
|
|
||||||
return self.snowflake_identifier(
|
return self.snowflake_identifier(
|
||||||
f"{user_name}@{self.identifier_config.email_domain}"
|
f"{user_name}@{self.identifier_config.email_domain}"
|
||||||
if self.identifier_config.email_as_user_identifier is True
|
if self.identifier_config.email_domain is not None
|
||||||
and self.identifier_config.email_domain is not None
|
|
||||||
else user_name
|
else user_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,6 @@ def test_snowflake_basic(pytestconfig, tmp_path, mock_time, mock_datahub_graph):
|
|||||||
format_sql_queries=True,
|
format_sql_queries=True,
|
||||||
validate_upstreams_against_patterns=False,
|
validate_upstreams_against_patterns=False,
|
||||||
include_operational_stats=True,
|
include_operational_stats=True,
|
||||||
email_as_user_identifier=True,
|
|
||||||
incremental_lineage=False,
|
incremental_lineage=False,
|
||||||
start_time=datetime(2022, 6, 6, 0, 0, 0, 0).replace(
|
start_time=datetime(2022, 6, 6, 0, 0, 0, 0).replace(
|
||||||
tzinfo=timezone.utc
|
tzinfo=timezone.utc
|
||||||
|
|||||||
@ -36,7 +36,6 @@ def test_user_identifiers_email_as_identifier(snowflake_connect, tmp_path):
|
|||||||
"username": "TST_USR",
|
"username": "TST_USR",
|
||||||
"password": "TST_PWD",
|
"password": "TST_PWD",
|
||||||
},
|
},
|
||||||
"email_as_user_identifier": True,
|
|
||||||
"email_domain": "example.com",
|
"email_domain": "example.com",
|
||||||
},
|
},
|
||||||
PipelineContext("run-id"),
|
PipelineContext("run-id"),
|
||||||
@ -63,7 +62,7 @@ def test_user_identifiers_email_as_identifier(snowflake_connect, tmp_path):
|
|||||||
|
|
||||||
|
|
||||||
@patch("snowflake.connector.connect")
|
@patch("snowflake.connector.connect")
|
||||||
def test_user_identifiers_username_as_identifier(snowflake_connect, tmp_path):
|
def test_user_identifiers_user_email_as_identifier(snowflake_connect, tmp_path):
|
||||||
source = SnowflakeQueriesSource.create(
|
source = SnowflakeQueriesSource.create(
|
||||||
{
|
{
|
||||||
"connection": {
|
"connection": {
|
||||||
@ -71,13 +70,12 @@ def test_user_identifiers_username_as_identifier(snowflake_connect, tmp_path):
|
|||||||
"username": "TST_USR",
|
"username": "TST_USR",
|
||||||
"password": "TST_PWD",
|
"password": "TST_PWD",
|
||||||
},
|
},
|
||||||
"email_as_user_identifier": False,
|
|
||||||
},
|
},
|
||||||
PipelineContext("run-id"),
|
PipelineContext("run-id"),
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
source.identifiers.get_user_identifier("username", "username@example.com")
|
source.identifiers.get_user_identifier("username", "username@example.com")
|
||||||
== "username"
|
== "username@example.com"
|
||||||
)
|
)
|
||||||
assert source.identifiers.get_user_identifier("username", None) == "username"
|
assert source.identifiers.get_user_identifier("username", None) == "username"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user