@@ -124,7 +124,11 @@ pub fn convert_static_schema_to_arrow_schema(
124
124
"boolean_list" => {
125
125
DataType :: List ( Arc :: new ( Field :: new ( "item" , DataType :: Boolean , true ) ) )
126
126
}
127
- _ => DataType :: Null ,
127
+ _ => {
128
+ return Err ( StaticSchemaError :: UnrecognizedDataType (
129
+ field. data_type . clone ( ) ,
130
+ ) ) ;
131
+ }
128
132
}
129
133
} ,
130
134
nullable : default_nullable ( ) ,
@@ -216,6 +220,9 @@ pub enum StaticSchemaError {
216
220
217
221
#[ error( "duplicate field name: {0}" ) ]
218
222
DuplicateField ( String ) ,
223
+
224
+ #[ error( "unrecognized data type: {0}" ) ]
225
+ UnrecognizedDataType ( String ) ,
219
226
}
220
227
221
228
#[ cfg( test) ]
@@ -233,4 +240,24 @@ mod tests {
233
240
let _ = validate_field_names ( "test_field" , & mut existing_field_names) ;
234
241
assert ! ( validate_field_names( "test_field" , & mut existing_field_names) . is_err( ) ) ;
235
242
}
243
+
244
+ #[ test]
245
+ fn unrecognized_data_type ( ) {
246
+ let static_schema = StaticSchema {
247
+ fields : vec ! [ SchemaFields {
248
+ name: "test_field" . to_string( ) ,
249
+ data_type: "unknown_type" . to_string( ) ,
250
+ } ] ,
251
+ } ;
252
+
253
+ let result = convert_static_schema_to_arrow_schema ( static_schema, "" , None ) ;
254
+
255
+ assert ! ( result. is_err( ) ) ;
256
+ match result. unwrap_err ( ) {
257
+ StaticSchemaError :: UnrecognizedDataType ( data_type) => {
258
+ assert_eq ! ( data_type, "unknown_type" ) ;
259
+ }
260
+ _ => panic ! ( "Expected UnrecognizedDataType error" ) ,
261
+ }
262
+ }
236
263
}
0 commit comments