From 832676effe7af930e259af90aef9d740ff4d8a3e Mon Sep 17 00:00:00 2001 From: Tsung-Ju Lii Date: Tue, 24 Sep 2024 15:25:43 +0800 Subject: [PATCH] address comments --- metaphor/kafka/config.py | 2 +- metaphor/postgresql/config.py | 8 ++++++++ tests/redshift/test_extractor.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/metaphor/kafka/config.py b/metaphor/kafka/config.py index be7d58ac..382b623e 100644 --- a/metaphor/kafka/config.py +++ b/metaphor/kafka/config.py @@ -141,7 +141,7 @@ class KafkaConfig(BaseConfig): """ bootstrap_servers: List[KafkaBootstrapServer] = dataclass_field( - default_factory=lambda: [] + default_factory=list ) """ The Kafka bootstrap servers / brokers. Cannot be empty. diff --git a/metaphor/postgresql/config.py b/metaphor/postgresql/config.py index 50f50b34..23e4fd26 100644 --- a/metaphor/postgresql/config.py +++ b/metaphor/postgresql/config.py @@ -1,6 +1,7 @@ from dataclasses import field from typing import Dict, Optional, Set +from pydantic import field_validator from pydantic.dataclasses import dataclass from metaphor.common.aws import AwsCredentials @@ -28,6 +29,13 @@ class QueryLogConfig: # Config to link user name to email so that Metaphor can display each query's issuer. username_to_email: Dict[str, str] = field(default_factory=dict) + @field_validator("username_to_email") + def _normalize_emails(cls, username_to_email: Dict[str, str]): + return { + k: v.lower() + for k, v + in username_to_email.items() + } @dataclass(config=ConnectorConfig) class BasePostgreSQLRunConfig(BaseConfig): diff --git a/tests/redshift/test_extractor.py b/tests/redshift/test_extractor.py index 9c19395a..03b7e880 100644 --- a/tests/redshift/test_extractor.py +++ b/tests/redshift/test_extractor.py @@ -97,7 +97,7 @@ async def __anext__(self): config.query_log = QueryLogConfig( username_to_email={ "user1": "user1@metaphor.io", - "user2": "user2@metaphor.io", + "user2": "USER2@METAPHOR.IO", } ) extractor = RedshiftExtractor(config)