-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
58 lines (43 loc) · 1.77 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from dataclasses import field
from typing import Optional, Set
from pydantic.dataclasses import dataclass
from metaphor.common.aws import AwsCredentials
from metaphor.common.base_config import BaseConfig
from metaphor.common.dataclass import ConnectorConfig
from metaphor.common.filter import DatasetFilter
from metaphor.common.sql.process_query.config import ProcessQueryConfig
@dataclass(config=ConnectorConfig)
class QueryLogConfig:
# Number of days back of query logs to fetch, if 0, don't fetch query logs
lookback_days: int = 1
# Query log filter to exclude certain usernames
excluded_usernames: Set[str] = field(default_factory=lambda: set())
# Config to control query processing
process_query: ProcessQueryConfig = field(
default_factory=lambda: ProcessQueryConfig(
ignore_command_statement=True
) # Ignore COMMAND statements by default
)
@dataclass(config=ConnectorConfig)
class BasePostgreSQLRunConfig(BaseConfig):
host: str
database: str
user: str
password: str
# Include or exclude specific databases/schemas/tables
filter: DatasetFilter = field(default_factory=lambda: DatasetFilter())
# configs for fetching query logs
query_log: QueryLogConfig = field(default_factory=lambda: QueryLogConfig())
port: int = 5432
@dataclass(config=ConnectorConfig)
class PostgreSQLQueryLogConfig(QueryLogConfig):
aws: Optional[AwsCredentials] = None
filter_pattern: Optional[str] = None
log_duration_enabled: bool = False
logs_group: Optional[str] = None
@dataclass(config=ConnectorConfig)
class PostgreSQLRunConfig(BasePostgreSQLRunConfig):
# configs for fetching query logs
query_log: PostgreSQLQueryLogConfig = field(
default_factory=lambda: PostgreSQLQueryLogConfig()
)