diff --git a/clickhouse_sqlalchemy/drivers/compilers/typecompiler.py b/clickhouse_sqlalchemy/drivers/compilers/typecompiler.py index 26647841..d8faa26c 100644 --- a/clickhouse_sqlalchemy/drivers/compilers/typecompiler.py +++ b/clickhouse_sqlalchemy/drivers/compilers/typecompiler.py @@ -131,3 +131,13 @@ def visit_map(self, type_, **kw): self.process(key_type, **kw), self.process(value_type, **kw) ) + + # TODO: Ensure that we can autogenerate with it...then open a pull request. + + def visit_aggregatefunction(self, type_): + print(type_.agg_name) + print(type_.nested_type) + return "AggregateFunction(%s, %s)" % ( + type_.agg_name, + self.process(value_type, **kw) + ) diff --git a/clickhouse_sqlalchemy/types/__init__.py b/clickhouse_sqlalchemy/types/__init__.py index 502e8a0f..8c95de04 100644 --- a/clickhouse_sqlalchemy/types/__init__.py +++ b/clickhouse_sqlalchemy/types/__init__.py @@ -33,6 +33,7 @@ 'Nested', 'Tuple', 'Map', + 'AggregateFunction', ] from .common import String diff --git a/clickhouse_sqlalchemy/types/common.py b/clickhouse_sqlalchemy/types/common.py index 947a8708..432a9d23 100644 --- a/clickhouse_sqlalchemy/types/common.py +++ b/clickhouse_sqlalchemy/types/common.py @@ -188,3 +188,12 @@ def __init__(self, key_type, value_type): self.key_type = key_type self.value_type = value_type super(Map, self).__init__() + + +class AggregateFunction(ClickHouseTypeEngine): + __visit_name__ = 'aggregatefunction' + + def __init__(self, agg_name, nested_type): + self.agg_name = agg_name + self.nested_type = to_instance(nested_type) + super(AggregateFunction, self).__init__()