Skip to content

Commit

Permalink
Merge pull request #112 from azat-archive/allow_suspicious_low_cardin…
Browse files Browse the repository at this point in the history
…ality_types

Set allow_suspicious_low_cardinality_types for LowCardinality tests
  • Loading branch information
xzkostyan committed Oct 16, 2019
2 parents 61f25ee + 072ccb3 commit 0cd9ab1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
env:
- VERSION=19.8.3.8 # SimpleAggregateFunction
- VERSION=19.15.3.6 # latest
- VERSION=19.9.2.4 # allow_suspicious_low_cardinality_types
- VERSION=19.8.3.8 # SimpleAggregateFunction
- VERSION=19.3.3
- VERSION=18.12.17
- VERSION=18.12.13
Expand Down
38 changes: 28 additions & 10 deletions tests/columns/test_low_cardinality.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@


class LowCardinalityTestCase(BaseTestCase):
stable_support_version = (19, 9, 2)

def cli_client_kwargs(self):
current = self.client.connection.server_info.version_tuple()
if current >= self.stable_support_version:
return {'allow_suspicious_low_cardinality_types': 1}
return {}

@require_server_version(19, 3, 3)
def test_uint8(self):
with self.create_table('a LowCardinality(UInt8)'):
with self.create_table('a LowCardinality(UInt8)',
**self.cli_client_kwargs()):
data = [(x, ) for x in range(255)]
self.client.execute('INSERT INTO test (a) VALUES', data)

Expand All @@ -24,7 +33,8 @@ def test_uint8(self):

@require_server_version(19, 3, 3)
def test_int8(self):
with self.create_table('a LowCardinality(Int8)'):
with self.create_table('a LowCardinality(Int8)',
**self.cli_client_kwargs()):
data = [(x - 127, ) for x in range(255)]
self.client.execute('INSERT INTO test (a) VALUES', data)

Expand All @@ -41,7 +51,8 @@ def test_int8(self):

@require_server_version(19, 3, 3)
def test_nullable_int8(self):
with self.create_table('a LowCardinality(Nullable(Int8))'):
with self.create_table('a LowCardinality(Nullable(Int8))',
**self.cli_client_kwargs()):
data = [(None, ), (-1, ), (0, ), (1, ), (None, )]
self.client.execute('INSERT INTO test (a) VALUES', data)

Expand All @@ -54,7 +65,8 @@ def test_nullable_int8(self):

@require_server_version(19, 3, 3)
def test_date(self):
with self.create_table('a LowCardinality(Date)'):
with self.create_table('a LowCardinality(Date)',
**self.cli_client_kwargs()):
start = date(1970, 1, 1)
data = [(start + timedelta(x), ) for x in range(300)]
self.client.execute('INSERT INTO test (a) VALUES', data)
Expand All @@ -65,7 +77,8 @@ def test_date(self):

@require_server_version(19, 3, 3)
def test_float(self):
with self.create_table('a LowCardinality(Float)'):
with self.create_table('a LowCardinality(Float)',
**self.cli_client_kwargs()):
data = [(float(x),) for x in range(300)]
self.client.execute('INSERT INTO test (a) VALUES', data)

Expand All @@ -75,7 +88,8 @@ def test_float(self):

@require_server_version(19, 3, 3)
def test_decimal(self):
with self.create_table('a LowCardinality(Float)'):
with self.create_table('a LowCardinality(Float)',
**self.cli_client_kwargs()):
data = [(Decimal(x),) for x in range(300)]
self.client.execute('INSERT INTO test (a) VALUES', data)

Expand All @@ -85,7 +99,8 @@ def test_decimal(self):

@require_server_version(19, 3, 3)
def test_array(self):
with self.create_table('a Array(LowCardinality(Int16))'):
with self.create_table('a Array(LowCardinality(Int16))',
**self.cli_client_kwargs()):
data = [((100, 500), )]
self.client.execute('INSERT INTO test (a) VALUES', data)

Expand All @@ -98,7 +113,8 @@ def test_array(self):

@require_server_version(19, 3, 3)
def test_empty_array(self):
with self.create_table('a Array(LowCardinality(Int16))'):
with self.create_table('a Array(LowCardinality(Int16))',
**self.cli_client_kwargs()):
data = [(tuple(), )]
self.client.execute('INSERT INTO test (a) VALUES', data)

Expand All @@ -111,7 +127,8 @@ def test_empty_array(self):

@require_server_version(19, 3, 3)
def test_string(self):
with self.create_table('a LowCardinality(String)'):
with self.create_table('a LowCardinality(String)',
**self.cli_client_kwargs()):
data = [
('test', ), ('low', ), ('cardinality', ),
('test', ), ('test', ), ('', )
Expand All @@ -130,7 +147,8 @@ def test_string(self):

@require_server_version(19, 3, 3)
def test_fixed_string(self):
with self.create_table('a LowCardinality(FixedString(12))'):
with self.create_table('a LowCardinality(FixedString(12))',
**self.cli_client_kwargs()):
data = [
('test', ), ('low', ), ('cardinality', ),
('test', ), ('test', ), ('', )
Expand Down

0 comments on commit 0cd9ab1

Please sign in to comment.