@@ -2383,6 +2383,7 @@ where
2383
2383
#[ cfg( test) ]
2384
2384
mod tests {
2385
2385
use super :: * ;
2386
+ use crate :: parse:: parse_decimal;
2386
2387
use arrow_buffer:: { Buffer , IntervalDayTime , NullBuffer } ;
2387
2388
use chrono:: NaiveDate ;
2388
2389
use half:: f16;
@@ -8416,92 +8417,92 @@ mod tests {
8416
8417
fn test_parse_string_to_decimal ( ) {
8417
8418
assert_eq ! (
8418
8419
Decimal128Type :: format_decimal(
8419
- parse_string_to_decimal_native :: <Decimal128Type >( "123.45" , 2 ) . unwrap( ) ,
8420
+ parse_decimal :: <Decimal128Type >( "123.45" , 38 , 2 ) . unwrap( ) ,
8420
8421
38 ,
8421
8422
2 ,
8422
8423
) ,
8423
8424
"123.45"
8424
8425
) ;
8425
8426
assert_eq ! (
8426
8427
Decimal128Type :: format_decimal(
8427
- parse_string_to_decimal_native :: <Decimal128Type >( "12345" , 2 ) . unwrap( ) ,
8428
+ parse_decimal :: <Decimal128Type >( "12345" , 38 , 2 ) . unwrap( ) ,
8428
8429
38 ,
8429
8430
2 ,
8430
8431
) ,
8431
8432
"12345.00"
8432
8433
) ;
8433
8434
assert_eq ! (
8434
8435
Decimal128Type :: format_decimal(
8435
- parse_string_to_decimal_native :: <Decimal128Type >( "0.12345" , 2 ) . unwrap( ) ,
8436
+ parse_decimal :: <Decimal128Type >( "0.12345" , 38 , 2 ) . unwrap( ) ,
8436
8437
38 ,
8437
8438
2 ,
8438
8439
) ,
8439
8440
"0.12"
8440
8441
) ;
8441
8442
assert_eq ! (
8442
8443
Decimal128Type :: format_decimal(
8443
- parse_string_to_decimal_native :: <Decimal128Type >( ".12345" , 2 ) . unwrap( ) ,
8444
+ parse_decimal :: <Decimal128Type >( ".12345" , 38 , 2 ) . unwrap( ) ,
8444
8445
38 ,
8445
8446
2 ,
8446
8447
) ,
8447
8448
"0.12"
8448
8449
) ;
8449
8450
assert_eq ! (
8450
8451
Decimal128Type :: format_decimal(
8451
- parse_string_to_decimal_native :: <Decimal128Type >( ".1265" , 2 ) . unwrap( ) ,
8452
+ parse_decimal :: <Decimal128Type >( ".1265" , 38 , 2 ) . unwrap( ) ,
8452
8453
38 ,
8453
8454
2 ,
8454
8455
) ,
8455
- "0.13 "
8456
+ "0.12 "
8456
8457
) ;
8457
8458
assert_eq ! (
8458
8459
Decimal128Type :: format_decimal(
8459
- parse_string_to_decimal_native :: <Decimal128Type >( ".1265" , 2 ) . unwrap( ) ,
8460
+ parse_decimal :: <Decimal128Type >( ".1265" , 38 , 2 ) . unwrap( ) ,
8460
8461
38 ,
8461
8462
2 ,
8462
8463
) ,
8463
- "0.13 "
8464
+ "0.12 "
8464
8465
) ;
8465
8466
8466
8467
assert_eq ! (
8467
8468
Decimal256Type :: format_decimal(
8468
- parse_string_to_decimal_native :: <Decimal256Type >( "123.45" , 3 ) . unwrap( ) ,
8469
+ parse_decimal :: <Decimal256Type >( "123.45" , 38 , 3 ) . unwrap( ) ,
8469
8470
38 ,
8470
8471
3 ,
8471
8472
) ,
8472
8473
"123.450"
8473
8474
) ;
8474
8475
assert_eq ! (
8475
8476
Decimal256Type :: format_decimal(
8476
- parse_string_to_decimal_native :: <Decimal256Type >( "12345" , 3 ) . unwrap( ) ,
8477
+ parse_decimal :: <Decimal256Type >( "12345" , 38 , 3 ) . unwrap( ) ,
8477
8478
38 ,
8478
8479
3 ,
8479
8480
) ,
8480
8481
"12345.000"
8481
8482
) ;
8482
8483
assert_eq ! (
8483
8484
Decimal256Type :: format_decimal(
8484
- parse_string_to_decimal_native :: <Decimal256Type >( "0.12345" , 3 ) . unwrap( ) ,
8485
+ parse_decimal :: <Decimal256Type >( "0.12345" , 38 , 3 ) . unwrap( ) ,
8485
8486
38 ,
8486
8487
3 ,
8487
8488
) ,
8488
8489
"0.123"
8489
8490
) ;
8490
8491
assert_eq ! (
8491
8492
Decimal256Type :: format_decimal(
8492
- parse_string_to_decimal_native :: <Decimal256Type >( ".12345" , 3 ) . unwrap( ) ,
8493
+ parse_decimal :: <Decimal256Type >( ".12345" , 38 , 3 ) . unwrap( ) ,
8493
8494
38 ,
8494
8495
3 ,
8495
8496
) ,
8496
8497
"0.123"
8497
8498
) ;
8498
8499
assert_eq ! (
8499
8500
Decimal256Type :: format_decimal(
8500
- parse_string_to_decimal_native :: <Decimal256Type >( ".1265" , 3 ) . unwrap( ) ,
8501
+ parse_decimal :: <Decimal256Type >( ".1265" , 38 , 3 ) . unwrap( ) ,
8501
8502
38 ,
8502
8503
3 ,
8503
8504
) ,
8504
- "0.127 "
8505
+ "0.126 "
8505
8506
) ;
8506
8507
}
8507
8508
0 commit comments