@@ -243,7 +243,10 @@ fn parse_decimal(type_str: &str) -> Result<Option<DataType>> {
243243 Ok ( Some ( DataType :: Decimal128 ( precision, scale) ) )
244244 }
245245 } ,
246- _ => Ok ( None ) ,
246+ n => Err ( DuckLakeError :: UnsupportedType ( format ! (
247+ "Invalid decimal type: expected at most 2 parameters (precision, scale), got {} in type '{}'" ,
248+ n, type_str
249+ ) ) ) ,
247250 }
248251}
249252
@@ -724,6 +727,37 @@ mod tests {
724727 assert ! ( result. is_err( ) ) ;
725728 }
726729
730+ #[ test]
731+ fn test_decimal_too_many_parameters_rejected ( ) {
732+ let result = ducklake_to_arrow_type ( "decimal(1,2,3)" ) ;
733+ assert ! ( result. is_err( ) ) ;
734+ match result {
735+ Err ( DuckLakeError :: UnsupportedType ( msg) ) => {
736+ assert ! ( msg. contains( "expected at most 2 parameters" ) ) ;
737+ assert ! ( msg. contains( "got 3" ) ) ;
738+ } ,
739+ _ => panic ! ( "Expected UnsupportedType error for 3 parameters" ) ,
740+ }
741+
742+ let result = ducklake_to_arrow_type ( "decimal(10,2,5,3)" ) ;
743+ assert ! ( result. is_err( ) ) ;
744+ match result {
745+ Err ( DuckLakeError :: UnsupportedType ( msg) ) => {
746+ assert ! ( msg. contains( "expected at most 2 parameters" ) ) ;
747+ assert ! ( msg. contains( "got 4" ) ) ;
748+ } ,
749+ _ => panic ! ( "Expected UnsupportedType error for 4 parameters" ) ,
750+ }
751+ }
752+
753+ #[ test]
754+ fn test_decimal_negative_scale_valid ( ) {
755+ assert_eq ! (
756+ ducklake_to_arrow_type( "decimal(10, -2)" ) . unwrap( ) ,
757+ DataType :: Decimal128 ( 10 , -2 )
758+ ) ;
759+ }
760+
727761 #[ test]
728762 fn test_build_schema_with_unsupported_type ( ) {
729763 // Test that build_arrow_schema propagates complex type errors
0 commit comments