@@ -91,6 +91,8 @@ pub enum LogicalTypeId {
9191 IntegerLiteral = DUCKDB_TYPE_DUCKDB_TYPE_INTEGER_LITERAL ,
9292 /// Time NS
9393 TimeNs = DUCKDB_TYPE_DUCKDB_TYPE_TIME_NS ,
94+ /// DuckDB returned a type that this wrapper does not yet recognize
95+ Unsupported = u32:: MAX ,
9496}
9597
9698impl From < u32 > for LogicalTypeId {
@@ -137,9 +139,8 @@ impl From<u32> for LogicalTypeId {
137139 DUCKDB_TYPE_DUCKDB_TYPE_STRING_LITERAL => Self :: StringLiteral ,
138140 DUCKDB_TYPE_DUCKDB_TYPE_INTEGER_LITERAL => Self :: IntegerLiteral ,
139141 DUCKDB_TYPE_DUCKDB_TYPE_TIME_NS => Self :: TimeNs ,
140- // Return Invalid for unknown types to handle forward compatibility
141- // when DuckDB adds new types in future versions
142- _ => Self :: Invalid ,
142+ // Unknown / forward compatible types
143+ _ => Self :: Unsupported ,
143144 }
144145 }
145146}
@@ -285,8 +286,12 @@ impl LogicalTypeHandle {
285286
286287 /// Logical type ID
287288 pub fn id ( & self ) -> LogicalTypeId {
288- let duckdb_type_id = unsafe { duckdb_get_type_id ( self . ptr ) } ;
289- duckdb_type_id. into ( )
289+ self . raw_id ( ) . into ( )
290+ }
291+
292+ /// Raw logical type id returned by DuckDB C API
293+ pub fn raw_id ( & self ) -> u32 {
294+ unsafe { duckdb_get_type_id ( self . ptr ) }
290295 }
291296
292297 /// Logical type children num
@@ -412,4 +417,9 @@ mod test {
412417 let debug_str = format ! ( "{invalid_type:?}" ) ;
413418 assert_eq ! ( debug_str, "Invalid" ) ;
414419 }
420+
421+ #[ test]
422+ fn test_unknown_type ( ) {
423+ assert_eq ! ( LogicalTypeId :: from( 999_999 ) , LogicalTypeId :: Unsupported ) ;
424+ }
415425}
0 commit comments