@@ -4,7 +4,9 @@ use arrow::array::{
44} ;
55use arrow:: datatypes:: { DataType , Schema , TimeUnit } ;
66use dbsp:: utils:: Tup2 ;
7- use feldera_sqllib:: { ByteArray , Date , SqlString , Time , Timestamp , Uuid , Variant , F32 , F64 } ;
7+ use feldera_sqllib:: {
8+ ByteArray , Date , SqlDecimal , SqlString , Time , Timestamp , Uuid , Variant , F32 , F64 ,
9+ } ;
810use feldera_types:: program_schema:: { ColumnType , Field , Relation , SqlIdentifier } ;
911use feldera_types:: {
1012 deserialize_table_record, deserialize_without_context, serialize_struct, serialize_table_record,
@@ -14,7 +16,6 @@ use proptest::{collection, prelude::*};
1416use proptest_derive:: Arbitrary ;
1517use rand:: distributions:: Standard ;
1618use rand:: prelude:: Distribution ;
17- use rust_decimal:: Decimal ;
1819use size_of:: SizeOf ;
1920use std:: collections:: BTreeMap ;
2021use std:: string:: ToString ;
@@ -324,7 +325,7 @@ pub struct TestStruct2 {
324325 pub field_5 : Option < EmbeddedStruct > ,
325326 #[ serde( rename = "m" ) ]
326327 pub field_6 : Option < BTreeMap < String , i64 > > ,
327- pub field_7 : Decimal ,
328+ pub field_7 : SqlDecimal ,
328329}
329330
330331impl Arbitrary for TestStruct2 {
@@ -362,7 +363,7 @@ impl Arbitrary for TestStruct2 {
362363 // field_4: Time::new(f4 * 1000),
363364 field_5 : Some ( f5) ,
364365 field_6 : Some ( f6) ,
365- field_7 : Decimal :: from_i128_with_scale ( f7_num, f7_scale) ,
366+ field_7 : SqlDecimal :: from_i128_with_scale ( f7_num, f7_scale as i32 ) ,
366367 } ,
367368 )
368369 . boxed ( )
@@ -384,7 +385,7 @@ impl TestStruct2 {
384385 ( "foo" . to_string( ) , 100 ) ,
385386 ( "bar" . to_string( ) , 200 ) ,
386387 ] ) ) ,
387- field_7: Decimal :: from_i128_with_scale( 10000 , 3 ) ,
388+ field_7: SqlDecimal :: from_i128_with_scale( 10000 , 3 ) ,
388389 } ,
389390 TestStruct2 {
390391 field: 2 ,
@@ -395,7 +396,7 @@ impl TestStruct2 {
395396 // field_4: Time::new(1_000_000_000),
396397 field_5: Some ( EmbeddedStruct { field: true } ) ,
397398 field_6: Some ( BTreeMap :: new( ) ) ,
398- field_7: Decimal :: from_i128_with_scale( 1 , 3 ) ,
399+ field_7: SqlDecimal :: from_i128_with_scale( 1 , 3 ) ,
399400 } ,
400401 ]
401402 }
@@ -604,7 +605,7 @@ serialize_table_record!(TestStruct2[8]{
604605 // r#field_4["t"]: Time,
605606 r#field_5[ "es" ] : Option <EmbeddedStruct >,
606607 r#field_6[ "m" ] : Option <Map <String , i64 >>,
607- r#field_7[ "dec" ] : Decimal
608+ r#field_7[ "dec" ] : SqlDecimal
608609} ) ;
609610
610611deserialize_table_record ! ( TestStruct2 [ "TestStruct" , 8 ] {
@@ -616,7 +617,7 @@ deserialize_table_record!(TestStruct2["TestStruct", 8] {
616617 // (r#field_4, "t", false, Time, None),
617618 ( r#field_5, "es" , false , Option <EmbeddedStruct >, Some ( None ) ) ,
618619 ( r#field_6, "m" , false , Option <BTreeMap <String , i64 >>, Some ( None ) ) ,
619- ( r#field_7, "dec" , false , Decimal , None )
620+ ( r#field_7, "dec" , false , SqlDecimal , None )
620621} ) ;
621622
622623/// Record in the databricks people dataset.
@@ -708,7 +709,7 @@ pub struct IcebergTestStruct {
708709 pub l : i64 ,
709710 pub r : F32 ,
710711 pub d : F64 ,
711- pub dec : Decimal ,
712+ pub dec : SqlDecimal ,
712713 pub dt : Date ,
713714 pub tm : Time ,
714715 pub ts : Timestamp ,
@@ -766,7 +767,7 @@ impl Arbitrary for IcebergTestStruct {
766767 l,
767768 r : F32 :: new ( r) ,
768769 d : F64 :: new ( d) ,
769- dec : Decimal :: from_i128_with_scale ( dec_num, dec_scale) ,
770+ dec : SqlDecimal :: from_i128_with_scale ( dec_num, dec_scale as i32 ) ,
770771 dt : Date :: new ( dt) ,
771772 tm : Time :: new ( tm) ,
772773 ts : Timestamp :: new ( ts) ,
@@ -859,7 +860,7 @@ serialize_table_record!(IcebergTestStruct[12]{
859860 l[ "l" ] : i64 ,
860861 r[ "r" ] : F32 ,
861862 d[ "d" ] : F64 ,
862- dec[ "dec" ] : Decimal ,
863+ dec[ "dec" ] : SqlDecimal ,
863864 dt[ "dt" ] : Date ,
864865 tm[ "tm" ] : Time ,
865866 ts[ "ts" ] : Timestamp ,
@@ -875,7 +876,7 @@ deserialize_table_record!(IcebergTestStruct["IcebergTestStruct", 12] {
875876 ( l, "l" , false , i64 , None ) ,
876877 ( r, "r" , false , F32 , None ) ,
877878 ( d, "d" , false , F64 , None ) ,
878- ( dec, "dec" , false , Decimal , None ) ,
879+ ( dec, "dec" , false , SqlDecimal , None ) ,
879880 ( dt, "dt" , false , Date , None ) ,
880881 ( tm, "tm" , false , Time , None ) ,
881882 ( ts, "ts" , false , Timestamp , None ) ,
@@ -906,7 +907,7 @@ pub struct DeltaTestStruct {
906907 pub binary : ByteArray ,
907908 pub boolean : bool ,
908909 pub date : Date ,
909- pub decimal_10_3 : Decimal ,
910+ pub decimal_10_3 : SqlDecimal ,
910911 pub double : F64 ,
911912 pub float : F32 ,
912913 pub int : i32 ,
@@ -988,7 +989,7 @@ impl Arbitrary for DeltaTestStruct {
988989 binary : ByteArray :: from_vec ( binary) ,
989990 boolean,
990991 date : Date :: new ( date) ,
991- decimal_10_3 : Decimal :: from_i128_with_scale ( decimal_digits, 3 ) ,
992+ decimal_10_3 : SqlDecimal :: from_i128_with_scale ( decimal_digits, 3 ) ,
992993 double : F64 :: new ( double. trunc ( ) ) , // truncate to avoid rounding errors when serializing floats to/from JSON
993994 float : F32 :: new ( float. trunc ( ) ) ,
994995 int,
@@ -1195,7 +1196,7 @@ serialize_table_record!(DeltaTestStruct[20]{
11951196 binary[ "binary" ] : ByteArray ,
11961197 boolean[ "boolean" ] : bool ,
11971198 date[ "date" ] : Date ,
1198- decimal_10_3[ "decimal_10_3" ] : Decimal ,
1199+ decimal_10_3[ "decimal_10_3" ] : SqlDecimal ,
11991200 double[ "double" ] : F64 ,
12001201 float[ "float" ] : F32 ,
12011202 int[ "int" ] : i32 ,
@@ -1218,7 +1219,7 @@ deserialize_table_record!(DeltaTestStruct["DeltaTestStruct", 20] {
12181219 ( binary, "binary" , false , ByteArray , None ) ,
12191220 ( boolean, "boolean" , false , bool , None ) ,
12201221 ( date, "date" , false , Date , None ) ,
1221- ( decimal_10_3, "decimal_10_3" , false , Decimal , None ) ,
1222+ ( decimal_10_3, "decimal_10_3" , false , SqlDecimal , None ) ,
12221223 ( double, "double" , false , F64 , None ) ,
12231224 ( float, "float" , false , F32 , None ) ,
12241225 ( int, "int" , false , i32 , None ) ,
0 commit comments