mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-08-02 03:00:09 +03:00
add support for arbitrary SETTINGS in CREATE TABLE
This commit is contained in:
parent
cd724c2132
commit
d7d30e8e65
|
@ -36,6 +36,7 @@ class MergeTree(Engine):
|
||||||
replica_name=None,
|
replica_name=None,
|
||||||
partition_key=None,
|
partition_key=None,
|
||||||
primary_key=None,
|
primary_key=None,
|
||||||
|
settings=None,
|
||||||
):
|
):
|
||||||
assert type(order_by) in (list, tuple), "order_by must be a list or tuple"
|
assert type(order_by) in (list, tuple), "order_by must be a list or tuple"
|
||||||
assert date_col is None or isinstance(date_col, str), "date_col must be string if present"
|
assert date_col is None or isinstance(date_col, str), "date_col must be string if present"
|
||||||
|
@ -47,6 +48,7 @@ class MergeTree(Engine):
|
||||||
assert (replica_table_path is None) == (
|
assert (replica_table_path is None) == (
|
||||||
replica_name is None
|
replica_name is None
|
||||||
), "both replica_table_path and replica_name must be specified"
|
), "both replica_table_path and replica_name must be specified"
|
||||||
|
assert settings is None or type(settings) is dict, 'settings must be dict'
|
||||||
|
|
||||||
# These values conflict with each other (old and new syntax of table engines.
|
# These values conflict with each other (old and new syntax of table engines.
|
||||||
# So let's control only one of them is given.
|
# So let's control only one of them is given.
|
||||||
|
@ -60,6 +62,7 @@ class MergeTree(Engine):
|
||||||
self.index_granularity = index_granularity
|
self.index_granularity = index_granularity
|
||||||
self.replica_table_path = replica_table_path
|
self.replica_table_path = replica_table_path
|
||||||
self.replica_name = replica_name
|
self.replica_name = replica_name
|
||||||
|
self.settings = settings
|
||||||
|
|
||||||
# I changed field name for new reality and syntax
|
# I changed field name for new reality and syntax
|
||||||
@property
|
@property
|
||||||
|
@ -97,6 +100,9 @@ class MergeTree(Engine):
|
||||||
partition_sql += " SAMPLE BY %s" % self.sampling_expr
|
partition_sql += " SAMPLE BY %s" % self.sampling_expr
|
||||||
|
|
||||||
partition_sql += " SETTINGS index_granularity=%d" % self.index_granularity
|
partition_sql += " SETTINGS index_granularity=%d" % self.index_granularity
|
||||||
|
if self.settings:
|
||||||
|
settings_sql = ", ".join('%s=%s' % (key, value) for key, value in self.settings.items())
|
||||||
|
partition_sql += ", " + settings_sql
|
||||||
|
|
||||||
elif not self.date_col:
|
elif not self.date_col:
|
||||||
# Can't import it globally due to circular import
|
# Can't import it globally due to circular import
|
||||||
|
@ -144,6 +150,7 @@ class CollapsingMergeTree(MergeTree):
|
||||||
replica_name=None,
|
replica_name=None,
|
||||||
partition_key=None,
|
partition_key=None,
|
||||||
primary_key=None,
|
primary_key=None,
|
||||||
|
settings=None,
|
||||||
):
|
):
|
||||||
super(CollapsingMergeTree, self).__init__(
|
super(CollapsingMergeTree, self).__init__(
|
||||||
date_col,
|
date_col,
|
||||||
|
@ -154,6 +161,7 @@ class CollapsingMergeTree(MergeTree):
|
||||||
replica_name,
|
replica_name,
|
||||||
partition_key,
|
partition_key,
|
||||||
primary_key,
|
primary_key,
|
||||||
|
settings=settings,
|
||||||
)
|
)
|
||||||
self.sign_col = sign_col
|
self.sign_col = sign_col
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user