@@ -60,6 +60,7 @@ DEF ARR_CLS = ']'
60
60
61
61
RE_TUPLE = re.compile(r " ^ Tuple\( ( . * ) \) $ " )
62
62
RE_ARRAY = re.compile(r " ^ Array\( ( . * ) \) $ " )
63
+ RE_NESTED = re.compile(r " ^ Nested\( ( . * ) \) $ " )
63
64
RE_NULLABLE = re.compile(r " ^ Nullable\( ( . * ) \) $ " )
64
65
RE_LOW_CARDINALITY = re.compile(r " ^ LowCardinality\( ( . * ) \) $ " )
65
66
RE_MAP = re.compile(r " ^ Map\( ( . * ) \) $ " )
@@ -590,6 +591,36 @@ cdef class ArrayType:
590
591
return self .p_type(value.decode())
591
592
592
593
594
+ cdef class NestedType:
595
+
596
+ cdef:
597
+ str name
598
+ bint container
599
+ tuple types
600
+
601
+ def __cinit__ (self , str name , bint container ):
602
+ self .name = name
603
+ self .container = container
604
+ self .types = tuple (
605
+ what_py_type(i.split()[1 ], container = True )
606
+ for i in RE_NESTED.findall(name)[0 ].split(' ,' )
607
+ )
608
+
609
+ cdef list _convert(self , str string):
610
+ return self .p_type(string)
611
+
612
+ cpdef list p_type(self , str string):
613
+ result = []
614
+ for val in seq_parser(string[1 :- 1 ]):
615
+ temp = []
616
+ for tp, elem in zip (self .types, seq_parser(val.strip(" ()" ))):
617
+ temp.append(tp.p_type(decode(elem.encode())))
618
+ result.append(tuple (temp))
619
+ return result
620
+
621
+ cpdef list convert(self , bytes value):
622
+ return self ._convert(value.decode())
623
+
593
624
cdef class NullableType:
594
625
595
626
cdef:
@@ -766,6 +797,7 @@ cdef dict CH_TYPES_MAPPING = {
766
797
" Decimal128" : DecimalType,
767
798
" IPv4" : IPv4Type,
768
799
" IPv6" : IPv6Type,
800
+ " Nested" : NestedType,
769
801
}
770
802
771
803
0 commit comments