diff --git a/.travis.yml b/.travis.yml index 70539a47..289860e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ env: - - VERSION=1.1.54276 + - VERSION=1.1.54327 language: python python: diff --git a/src/columns/intervalcolumn.py b/src/columns/intervalcolumn.py new file mode 100644 index 00000000..94d31afc --- /dev/null +++ b/src/columns/intervalcolumn.py @@ -0,0 +1,33 @@ +from .intcolumn import Int64Column + + +class IntervalColumn(Int64Column): + pass + + +class IntervalDayColumn(IntervalColumn): + ch_type = 'IntervalDay' + + +class IntervalWeekColumn(IntervalColumn): + ch_type = 'IntervalWeek' + + +class IntervalMonthColumn(IntervalColumn): + ch_type = 'IntervalMonth' + + +class IntervalYearColumn(IntervalColumn): + ch_type = 'IntervalYear' + + +class IntervalHourColumn(IntervalColumn): + ch_type = 'IntervalHour' + + +class IntervalMinuteColumn(IntervalColumn): + ch_type = 'IntervalMinute' + + +class IntervalSecondColumn(IntervalColumn): + ch_type = 'IntervalSecond' diff --git a/src/columns/service.py b/src/columns/service.py index b1461cd2..76cedfae 100644 --- a/src/columns/service.py +++ b/src/columns/service.py @@ -13,13 +13,21 @@ from .nullablecolumn import create_nullable_column from .stringcolumn import String, FixedString from .uuidcolumn import UUIDColumn +from .intervalcolumn import ( + IntervalYearColumn, IntervalMonthColumn, IntervalWeekColumn, + IntervalDayColumn, IntervalHourColumn, IntervalMinuteColumn, + IntervalSecondColumn +) column_by_type = {c.ch_type: c for c in [ DateColumn, DateTimeColumn, String, Float32, Float64, Int8Column, Int16Column, Int32Column, Int64Column, UInt8Column, UInt16Column, UInt32Column, UInt64Column, - NullColumn, UUIDColumn + NullColumn, UUIDColumn, + IntervalYearColumn, IntervalMonthColumn, IntervalWeekColumn, + IntervalDayColumn, IntervalHourColumn, IntervalMinuteColumn, + IntervalSecondColumn ]} diff --git a/tests/columns/test_interval.py b/tests/columns/test_interval.py new file mode 100644 index 00000000..40f98e23 --- /dev/null +++ b/tests/columns/test_interval.py @@ -0,0 +1,24 @@ +from tests.testcase import BaseTestCase + + +class IntervalTestCase(BaseTestCase): + + def test_all(self): + interval = [ + ('YEAR', 1), + ('MONTH', 2), + ('WEEK', 3), + ('DAY', 4), + ('HOUR', 5), + ('MINUTE', 6), + ('SECOND', 7) + ] + columns = ', '.join(['INTERVAL {} {}'.format(v, k) + for k, v in interval]) + query = 'SELECT {}'.format(columns) + + cli_result = self.emit_cli(query) + self.assertEqual(cli_result, '1\t2\t3\t4\t5\t6\t7\n') + + client_result = self.client.execute(query) + self.assertEqual(client_result, [(1, 2, 3, 4, 5, 6, 7)])