mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-08 13:36:32 +00:00
fix: use enum.Enum instead of sqlalchemy enum (#18464)
This commit is contained in:
parent
9efe137466
commit
729a06b5f0
@ -14,10 +14,11 @@ Custom types' registry for easy access
|
||||
without having an import mess
|
||||
"""
|
||||
import math
|
||||
from enum import Enum
|
||||
|
||||
import sqlalchemy
|
||||
from sqlalchemy import Date, DateTime, Integer, Numeric, Time
|
||||
from sqlalchemy.sql.sqltypes import Concatenable, Enum
|
||||
from sqlalchemy.sql.sqltypes import Concatenable
|
||||
|
||||
from metadata.generated.schema.entity.data.table import DataType
|
||||
from metadata.ingestion.source import sqa_types
|
||||
@ -45,7 +46,7 @@ class CustomTypes(TypeRegistry):
|
||||
UNDETERMINED = UndeterminedType
|
||||
|
||||
|
||||
class Dialects(Enum):
|
||||
class PythonDialects(Enum):
|
||||
"""
|
||||
Map the service types from DatabaseServiceType
|
||||
to the dialect scheme name used for ingesting
|
||||
@ -54,6 +55,8 @@ class Dialects(Enum):
|
||||
Keep this alphabetically ordered
|
||||
"""
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
Athena = "awsathena"
|
||||
AzureSQL = "azuresql"
|
||||
BigQuery = "bigquery"
|
||||
@ -83,6 +86,28 @@ class Dialects(Enum):
|
||||
Vertica = "vertica"
|
||||
|
||||
|
||||
class EnumAdapter(type):
|
||||
"""A hack to use the Dialects string values can be accesses
|
||||
without using the value attribute.
|
||||
|
||||
Example:
|
||||
Dialets.MySQL == "mysql"
|
||||
|
||||
Instead of:
|
||||
Dialects.MySQL.value == "mysql"
|
||||
|
||||
We use this functionality when registring sqlalchemy custom functions. But we should
|
||||
avoid using this pattern as it can be confusing.
|
||||
"""
|
||||
|
||||
def __getattr__(cls, item):
|
||||
return PythonDialects[item].value
|
||||
|
||||
|
||||
class Dialects(metaclass=EnumAdapter):
|
||||
pass
|
||||
|
||||
|
||||
# Sometimes we want to skip certain types for computing metrics.
|
||||
# If the type is NULL, then we won't run the metric execution
|
||||
# in the profiler.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user