Skip to content

try add LowCardinality(Nullable(String)) #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,27 @@ def create_ad_hoc_field(cls, db_type):
if db_type == 'LowCardinality(String)':
db_type = 'String'

if db_type == 'Bool':
db_type = 'UInt8'

if db_type == 'LowCardinality(Nullable(String))':
db_type = 'String'

if db_type == 'Map(String, UInt64)':
db_type = 'String'

if db_type.startswith('DateTime'):
db_type = 'DateTime'

if db_type.startswith('Nullable'):
inner_field = cls.create_ad_hoc_field(db_type[9 : -1])
return orm_fields.NullableField(inner_field)

# db_type for Deimal comes like 'Decimal(P, S) string where P is precision and S is scale'
if db_type.startswith('Decimal'):
nums = [int(n) for n in db_type[8:-1].split(',')]
return orm_fields.DecimalField(nums[0], nums[1])

# Simple fields
name = db_type + 'Field'
if not hasattr(orm_fields, name):
Expand Down
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
VERSION = [0, 1, 5]
readme = open('README.rst').read()

dialects = [
'clickhouse{}=sqlalchemy_clickhouse.{}'.format(driver, d_path)

for driver, d_path in [
('', 'base:ClickHouseDialect'),
('.http', 'base:ClickHouseDialect'),
('.native', 'base:ClickHouseDialect')
]
]

setup(
name='sqlalchemy-clickhouse',
version='.'.join('%d' % v for v in VERSION[0:3]),
Expand All @@ -32,9 +42,7 @@
'sqlalchemy_clickhouse': ['LICENSE.txt'],
},
entry_points={
'sqlalchemy.dialects': [
'clickhouse=sqlalchemy_clickhouse.base',
]
'sqlalchemy.dialects': dialects
},
classifiers = [
'Development Status :: 5 - Production/Stable',
Expand Down