You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am unable to deserialze an avro record with a Bigdecimal field. Given this minimal test:
#[test]
fn minimal() {
#[derive(Debug, serde::Deserialize)]
struct Test {
decimal: apache_avro::Decimal,
}
let decimal_value = Value::Decimal(Decimal::from(vec![1, 24]));
let record = Value::Record(vec![("decimal".to_string(), decimal_value)]);
let deserialize_result = from_value::<Test>(&record);
dbg!(deserialize_result);
}
The output is deserialize_result = Err( Failed to deserialize Avro value into value: Expected a Record or Union, got: Decimal(Decimal { value: 280, len: 2 }), )
I can get it to work as expected by changing the implementation of Decimal to use a custom implementation of Serialize and Deserialize instead of relying on derive:
Activity
martin-g commentedon Nov 5, 2024
Help is welcome!
I have no experience with this part of the code and I won't have time to look deeper into this issue in the next few weeks.
ollis commentedon Nov 6, 2024
I can get it to work as expected by changing the implementation of Decimal to use a custom implementation of Serialize and Deserialize instead of relying on derive:
martin-g commentedon Nov 6, 2024
Awesome!
Please send a Pull Request!
ollis commentedon Nov 7, 2024
#48
Issue apache#40 - Minor cleanup
Use custom serde serialization and deserialization for avro decimal (#48