Skip to content

Commit

Permalink
Add aggregate types
Browse files Browse the repository at this point in the history
  • Loading branch information
aronbierbaum committed Mar 2, 2024
1 parent 8c56735 commit b1ff4ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions clickhouse_sqlalchemy/drivers/compilers/typecompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
1 change: 1 addition & 0 deletions clickhouse_sqlalchemy/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'Nested',
'Tuple',
'Map',
'AggregateFunction',
]

from .common import String
Expand Down
9 changes: 9 additions & 0 deletions clickhouse_sqlalchemy/types/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()

0 comments on commit b1ff4ba

Please sign in to comment.