Skip to content

Commit 4de3720

Browse files
committed
Remove most references to rust_decimal
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent 0db6244 commit 4de3720

File tree

40 files changed

+364
-1370
lines changed

40 files changed

+364
-1370
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ rkyv = { version = "0.7.45", default-features = false }
175175
rmp-serde = "1.3.0"
176176
rmpv = "1.3.0"
177177
rstest = "0.15"
178-
rust_decimal = "1.33.1-feldera.1"
179-
rust_decimal_macros = "1.32"
180178
# Make sure this is the same rustls version used by the `tonic` crate.
181179
# See the `ensure_default_crypto_provider` function.
182180
rustls = "0.23.12"

crates/adapters/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ deltalake = { workspace = true, features = ["datafusion", "s3", "gcs", "azure"],
8686
apache-avro = { workspace = true, optional = true }
8787
schema_registry_converter = { workspace = true, features = ["avro", "blocking"], optional = true }
8888
rust_decimal = { package = "feldera_rust_decimal", version = "1.33.1-feldera.1", features = ["tokio-pg"] }
89+
rust_decimal_macros = "1.32"
8990
url = { workspace = true }
9091
metrics = { workspace = true }
9192
metrics-util = { workspace = true }
@@ -128,6 +129,7 @@ feldera-ir = { workspace = true }
128129
base64 = {workspace = true }
129130
aws-msk-iam-sasl-signer = "1.0.0"
130131
aws-credential-types = "1.2.3"
132+
feldera-sqllib = { workspace = true }
131133

132134
[package.metadata.cargo-machete]
133135
ignored = ["num-traits"]
@@ -151,9 +153,7 @@ futures-timer = { workspace = true }
151153
test_bin = { workspace = true }
152154
reqwest = { workspace = true, features = ["blocking"] }
153155
serial_test = { workspace = true }
154-
rust_decimal_macros = { workspace = true }
155156
mockall = { workspace = true }
156157
pretty_assertions = { workspace = true }
157-
feldera-sqllib = { workspace = true }
158158
google-cloud-googleapis = { workspace = true }
159159
postgres-types = { version = "0.2.9", features = ["derive"] }

crates/adapters/src/format/avro/deserializer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ fn deserialize_decimal<E: serde::de::Error>(d: &Decimal, schema: &Schema) -> Res
5454
};
5555

5656
// TODO: this is really expensive, and can be optimized by passing a binary representation of
57-
// mantissa + scale. This will require a customer `DeserializeWithContext` implementation for
58-
// rust_decimal::Decimal.
57+
// mantissa + scale. This will require a custom `DeserializeWithContext` implementation for
58+
// SqlDecimal.
5959
let bigdecimal = BigDecimal::new(BigInt::from(d.clone()), schema.scale as i64);
6060
Ok(bigdecimal.to_string())
6161
}

crates/adapters/src/format/avro/serializer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ mod test {
792792
from_avro_datum, to_avro_datum, types::Value as AvroValue, Decimal, Schema as AvroSchema,
793793
};
794794
use dbsp::algebra::{F32, F64};
795-
use feldera_sqllib::{Date, Timestamp};
795+
use feldera_sqllib::{Date, SqlDecimal, Timestamp};
796796
use feldera_types::{serde_with_context::SerializeWithContext, serialize_table_record};
797797
use num_bigint::BigInt;
798798
use rust_decimal::Decimal as RustDecimal;
@@ -935,7 +935,7 @@ mod test {
935935
("foo".to_string(), 1),
936936
("bar".to_string(), 2),
937937
])),
938-
field_7: rust_decimal::Decimal::new(10000, 3),
938+
field_7: SqlDecimal::from_i128_with_scale(10000i128, 3i32),
939939
};
940940

941941
let avro2_1: AvroValue = AvroValue::Record(vec![

crates/adapters/src/test/data.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use arrow::array::{
44
};
55
use arrow::datatypes::{DataType, Schema, TimeUnit};
66
use 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+
};
810
use feldera_types::program_schema::{ColumnType, Field, Relation, SqlIdentifier};
911
use feldera_types::{
1012
deserialize_table_record, deserialize_without_context, serialize_struct, serialize_table_record,
@@ -14,7 +16,6 @@ use proptest::{collection, prelude::*};
1416
use proptest_derive::Arbitrary;
1517
use rand::distributions::Standard;
1618
use rand::prelude::Distribution;
17-
use rust_decimal::Decimal;
1819
use size_of::SizeOf;
1920
use std::collections::BTreeMap;
2021
use 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

330331
impl 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

610611
deserialize_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),

crates/adapters/src/transport/redis/test.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use feldera_sqllib::{ByteArray, Date, SqlString, Timestamp, Uuid, Variant, F32, F64};
1+
use feldera_sqllib::{ByteArray, Date, SqlDecimal, SqlString, Timestamp, Uuid, Variant, F32, F64};
22
use feldera_types::{
33
config::PipelineConfig,
44
format::json::JsonFlavor,
55
serde_with_context::{SerializeWithContext, SqlSerdeConfig},
66
};
77
use redis::Commands;
8-
use rust_decimal::Decimal;
98
use serde_json::json;
109
use std::{
1110
collections::{BTreeMap, HashSet},
@@ -34,7 +33,7 @@ fn test_redis_output() {
3433
binary: ByteArray::new(&[0, 1, 2]),
3534
boolean: false,
3635
date: Date::new(1),
37-
decimal_10_3: Decimal::new(123, 2),
36+
decimal_10_3: SqlDecimal::from_i128_with_scale(123i128, 2),
3837
double: F64::from_str("1.123").unwrap(),
3938
float: F32::from_str("1.123").unwrap(),
4039
int: 1,

crates/dbsp/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ crossbeam = { workspace = true }
4242
arc-swap = { workspace = true }
4343
mimalloc-rust-sys = { workspace = true }
4444
rand = { workspace = true }
45-
rust_decimal = { package = "feldera_rust_decimal", version = "1.33.1-feldera.1" }
4645
rkyv = { workspace = true, features = ["std", "size_64", "validation", "uuid"] }
4746
size-of = { workspace = true, features = [
4847
"hashbrown",

crates/dbsp/src/algebra/mod.rs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub use zset::{
2222
};
2323

2424
use num::PrimInt;
25-
use rust_decimal::{prelude::One, prelude::Zero, Decimal};
2625
use size_of::SizeOf;
2726
use std::{
2827
fmt::{Debug, Display},
@@ -165,18 +164,6 @@ impl_has_zero! {
165164
isize,
166165
}
167166

168-
impl HasZero for Decimal {
169-
#[inline]
170-
fn is_zero(&self) -> bool {
171-
Zero::is_zero(self)
172-
}
173-
174-
#[inline]
175-
fn zero() -> Self {
176-
Zero::zero()
177-
}
178-
}
179-
180167
impl<T> HasZero for Option<T> {
181168
#[inline]
182169
fn is_zero(&self) -> bool {
@@ -226,13 +213,6 @@ macro_rules! impl_has_one {
226213
};
227214
}
228215

229-
impl HasOne for Decimal {
230-
#[inline]
231-
fn one() -> Self {
232-
One::one()
233-
}
234-
}
235-
236216
impl_has_one! {
237217
u8,
238218
i8,
@@ -454,15 +434,6 @@ impl MulByRef<isize> for F64 {
454434
}
455435
}
456436

457-
impl MulByRef<isize> for Decimal {
458-
type Output = Self;
459-
460-
#[inline]
461-
fn mul_by_ref(&self, w: &isize) -> Self::Output {
462-
*self * Decimal::from(*w)
463-
}
464-
}
465-
466437
/////////// `MulByRef<i64>`
467438

468439
impl MulByRef<i64> for i8 {
@@ -537,15 +508,6 @@ impl MulByRef<i64> for F64 {
537508
}
538509
}
539510

540-
impl MulByRef<i64> for Decimal {
541-
type Output = Self;
542-
543-
#[inline]
544-
fn mul_by_ref(&self, w: &i64) -> Self::Output {
545-
*self * Decimal::from(*w)
546-
}
547-
}
548-
549511
/////////// `MulByRef<i32>`
550512

551513
impl MulByRef<i32> for i8 {
@@ -620,15 +582,6 @@ impl MulByRef<i32> for F64 {
620582
}
621583
}
622584

623-
impl MulByRef<i32> for Decimal {
624-
type Output = Self;
625-
626-
#[inline]
627-
fn mul_by_ref(&self, w: &i32) -> Self::Output {
628-
*self * Decimal::from(*w)
629-
}
630-
}
631-
632585
/////////// generic implementation for Option<t>
633586

634587
pub trait OptionWeightType {}
@@ -641,7 +594,6 @@ impl OptionWeightType for f32 {}
641594
impl OptionWeightType for f64 {}
642595
impl OptionWeightType for F32 {}
643596
impl OptionWeightType for F64 {}
644-
impl OptionWeightType for Decimal {}
645597
impl OptionWeightType for Present {}
646598

647599
impl<T, S> MulByRef<S> for Option<T>

crates/dbsp/src/algebra/present.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::algebra::{HasOne, HasZero, MulByRef};
22
use rkyv::{Archive, Deserialize, Serialize};
3-
use rust_decimal::Decimal;
43
use size_of::SizeOf;
54
use std::ops::{Mul, MulAssign, Neg, Sub, SubAssign};
65

@@ -107,7 +106,6 @@ make_mul!(i32);
107106
make_mul!(i64);
108107
make_mul!(F32);
109108
make_mul!(F64);
110-
make_mul!(Decimal);
111109

112110
// FIXME: This doesn't really make sense and is wrong
113111
impl Neg for Present {

crates/feldera-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ thiserror = { workspace = true }
3131
regex = { workspace = true }
3232

3333
[dev-dependencies]
34-
rust_decimal_macros = { workspace = true }
34+
rust_decimal_macros = "1.32"
3535
csv = { workspace = true }
3636
tempfile = { workspace = true }

0 commit comments

Comments
 (0)