mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 09:06:41 +03:00
Support LowCardinality columns in ad-hoc queries
This commit is contained in:
parent
4749918014
commit
4848c7f813
|
@ -1,6 +1,10 @@
|
|||
Change Log
|
||||
==========
|
||||
|
||||
Unreleased
|
||||
----------
|
||||
- Support LowCardinality columns in ad-hoc queries
|
||||
|
||||
v1.2.0
|
||||
------
|
||||
- Add support for per-field compression codecs (rbelio, Chocorean)
|
||||
|
|
|
@ -88,6 +88,10 @@ class ModelBase(type):
|
|||
if db_type.startswith('Nullable'):
|
||||
inner_field = cls.create_ad_hoc_field(db_type[9 : -1])
|
||||
return orm_fields.NullableField(inner_field)
|
||||
# LowCardinality
|
||||
if db_type.startswith('LowCardinality'):
|
||||
inner_field = cls.create_ad_hoc_field(db_type[15 : -1])
|
||||
return orm_fields.LowCardinalityField(inner_field)
|
||||
# Simple fields
|
||||
name = db_type + 'Field'
|
||||
if not hasattr(orm_fields, name):
|
||||
|
|
|
@ -35,7 +35,7 @@ class TestCaseWithData(unittest.TestCase):
|
|||
class Person(Model):
|
||||
|
||||
first_name = StringField()
|
||||
last_name = StringField()
|
||||
last_name = LowCardinalityField(StringField())
|
||||
birthday = DateField()
|
||||
height = Float32Field()
|
||||
passport = NullableField(UInt32Field())
|
||||
|
|
|
@ -209,3 +209,12 @@ class DatabaseTestCase(TestCaseWithData):
|
|||
# Remove the setting and see that now it works
|
||||
self.database.add_setting('max_columns_to_read', None)
|
||||
list(self.database.select('SELECT * from system.tables'))
|
||||
|
||||
def test_create_ad_hoc_field(self):
|
||||
# Tests that create_ad_hoc_field works for all column types in the database
|
||||
from infi.clickhouse_orm.models import ModelBase
|
||||
query = "SELECT DISTINCT type FROM system.columns"
|
||||
for row in self.database.select(query):
|
||||
if row.type in ('IPv4', 'IPv6'):
|
||||
continue # unsupported yet
|
||||
ModelBase.create_ad_hoc_field(row.type)
|
||||
|
|
Loading…
Reference in New Issue
Block a user