Fix: aggregate type (#9138)

This commit is contained in:
NiharDoshi99 2022-12-05 14:50:37 +05:30 committed by GitHub
parent 5049c7db04
commit e0a3f3481b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -12,11 +12,12 @@
import enum
import traceback
from clickhouse_sqlalchemy.drivers.base import ClickHouseDialect
from clickhouse_sqlalchemy.drivers.base import ClickHouseDialect, ischema_names
from clickhouse_sqlalchemy.drivers.http.transport import RequestsTransport, _get_type
from clickhouse_sqlalchemy.drivers.http.utils import parse_tsv
from sqlalchemy import types as sqltypes
from sqlalchemy.engine import reflection
from sqlalchemy.sql.sqltypes import String
from sqlalchemy.util import warn
from metadata.generated.schema.entity.services.connections.database.clickhouseConnection import (
@ -35,10 +36,17 @@ from metadata.utils.logger import ingestion_logger
logger = ingestion_logger()
class AggregateFunction(String):
__visit_name__ = "AggregateFunction"
@reflection.cache
def _get_column_type(
self, name, spec
): # pylint: disable=protected-access,too-many-branches,too-many-return-statements
ischema_names.update({"AggregateFunction": AggregateFunction})
ClickHouseDialect.ischema_names = ischema_names
if spec.startswith("Array"):
inner = spec[6:-1]
coltype = self.ischema_names["_array"]
@ -95,6 +103,8 @@ def _get_column_type(
coltype = self.ischema_names["Decimal"]
return coltype(*self._parse_decimal_params(spec))
if spec.lower().startswith("aggregatefunction"):
return self.ischema_names["AggregateFunction"]
try:
return self.ischema_names[spec]
except KeyError:

View File

@ -192,6 +192,7 @@ class ColumnTypeParser:
"UUID": "UUID",
"POINT": "POINT",
"POLYGON": "POLYGON",
"AggregateFunction()": "AGGREGATEFUNCTION",
"BYTEA": "BYTEA",
}

View File

@ -96,7 +96,8 @@
"GEOMETRY",
"POINT",
"POLYGON",
"BYTEA"
"BYTEA",
"AGGREGATEFUNCTION"
]
},
"constraint": {