3131 # Date/Time Types
3232 "date" : RustWrenEngineColumnType .DATE ,
3333 "datetime" : RustWrenEngineColumnType .TIMESTAMP ,
34+ "datetime64" : RustWrenEngineColumnType .TIMESTAMP ,
3435 # String Types
3536 "string" : RustWrenEngineColumnType .VARCHAR ,
3637 "fixedstring" : RustWrenEngineColumnType .CHAR ,
@@ -89,11 +90,12 @@ def get_table_list(self) -> list[Table]:
8990 )
9091
9192 # table exists, and add column to the table
93+ is_nullable = 'nullable(' in row ["data_type" ].lower ()
9294 unique_tables [schema_table ].columns .append (
9395 Column (
9496 name = row ["column_name" ],
9597 type = self ._transform_column_type (row ["data_type" ]),
96- notNull = False ,
98+ notNull = not is_nullable ,
9799 description = row ["column_comment" ],
98100 properties = None ,
99101 )
@@ -119,7 +121,9 @@ def _transform_column_type(self, data_type: str) -> RustWrenEngineColumnType:
119121 The corresponding RustWrenEngineColumnType
120122 """
121123 # Convert to lowercase for comparison
122- normalized_type = data_type .lower ()
124+ # Extract inner type from wrappers like Nullable(...), Array(...), etc.
125+ inner_type = self ._extract_inner_type (data_type )
126+ normalized_type = inner_type .lower ()
123127
124128 # Use the module-level mapping table
125129 mapped_type = CLICKHOUSE_TYPE_MAPPING .get (
@@ -130,3 +134,25 @@ def _transform_column_type(self, data_type: str) -> RustWrenEngineColumnType:
130134 logger .warning (f"Unknown ClickHouse data type: { data_type } " )
131135
132136 return mapped_type
137+
138+ def _extract_inner_type (self , data_type : str ) -> str :
139+ """Extract the inner type from ClickHouse type definitions.
140+
141+ This handles types wrapped in Nullable(...), Array(...), etc.
142+
143+ Args:
144+ data_type: The ClickHouse data type string
145+
146+ Returns:
147+ The extracted inner type string
148+ """
149+
150+ if '(' in data_type and data_type .endswith (')' ):
151+ paren_start = data_type .find ('(' )
152+ type_name = data_type [:paren_start ].lower ()
153+ inner = data_type [paren_start + 1 :- 1 ]
154+
155+ if type_name in ['nullable' , 'array' , 'lowcardinality' ]:
156+ return self ._extract_inner_type (inner )
157+ else :
158+ return type_name
0 commit comments