[prev in list] [next in list] [prev in thread] [next in thread] 

List:       avro-commits
Subject:    (avro) branch main updated: AVRO-3948: [Rust] Re-export bigdecimal::BigDecimal as apache_avro::BigDe
From:       mgrigorov () apache ! org
Date:       2024-02-27 9:52:35
Message-ID: 170902755567.3412671.17469022198203643081 () gitbox2-he-fi ! apache ! org
[Download RAW message or body]

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/main by this push:
     new 87f7fd2df AVRO-3948: [Rust] Re-export bigdecimal::BigDecimal as apache_avro::BigDecimal (#2771)
87f7fd2df is described below

commit 87f7fd2df9578ae2f3276b62debd52b5101621c3
Author: Martin Grigorov <martin-g@users.noreply.github.com>
AuthorDate: Tue Feb 27 11:52:29 2024 +0200

    AVRO-3948: [Rust] Re-export bigdecimal::BigDecimal as apache_avro::BigDecimal (#2771)
    
    Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
---
 lang/rust/avro/src/bigdecimal.rs    |  2 +-
 lang/rust/avro/src/lib.rs           |  1 +
 lang/rust/avro/tests/avro-3786.rs   | 36 ++++++++++++++++++------------------
 lang/rust/avro/tests/big_decimal.rs | 23 +++++++++++++++++++++++
 4 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/lang/rust/avro/src/bigdecimal.rs b/lang/rust/avro/src/bigdecimal.rs
index 65ddf9733..a4e503b13 100644
--- a/lang/rust/avro/src/bigdecimal.rs
+++ b/lang/rust/avro/src/bigdecimal.rs
@@ -21,7 +21,7 @@ use crate::{
     types::Value,
     Error,
 };
-use bigdecimal::BigDecimal;
+pub use bigdecimal::BigDecimal;
 use num_bigint::BigInt;
 use std::io::Read;
 
diff --git a/lang/rust/avro/src/lib.rs b/lang/rust/avro/src/lib.rs
index 9d5dcb83c..ca05c2f54 100644
--- a/lang/rust/avro/src/lib.rs
+++ b/lang/rust/avro/src/lib.rs
@@ -820,6 +820,7 @@ pub mod schema_equality;
 pub mod types;
 pub mod validator;
 
+pub use crate::bigdecimal::BigDecimal;
 pub use codec::Codec;
 pub use de::from_value;
 pub use decimal::Decimal;
diff --git a/lang/rust/avro/tests/avro-3786.rs b/lang/rust/avro/tests/avro-3786.rs
index d27e0c4e5..a0e7714f5 100644
--- a/lang/rust/avro/tests/avro-3786.rs
+++ b/lang/rust/avro/tests/avro-3786.rs
@@ -127,15 +127,15 @@ fn avro_3786_deserialize_union_with_different_enum_order() -> TestResult {
         bar_init: Bar::Bar1,
         bar_use_parent: Some(BarUseParent { bar_use: Bar::Bar1 }),
     };
-    let avro_value = crate::to_value(foo1)?;
+    let avro_value = to_value(foo1)?;
     assert!(
         avro_value.validate(&writer_schema),
         "value is valid for schema",
     );
-    let datum = crate::to_avro_datum(&writer_schema, avro_value)?;
+    let datum = to_avro_datum(&writer_schema, avro_value)?;
     let mut x = &datum[..];
     let reader_schema = Schema::parse_str(reader_schema)?;
-    let deser_value = crate::from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
+    let deser_value = from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
     match deser_value {
         types::Value::Record(fields) => {
             assert_eq!(fields.len(), 2);
@@ -251,15 +251,15 @@ fn avro_3786_deserialize_union_with_different_enum_order_defined_in_record() ->
     let foo1 = Foo {
         bar_parent: Some(BarParent { bar: Bar::Bar0 }),
     };
-    let avro_value = crate::to_value(foo1)?;
+    let avro_value = to_value(foo1)?;
     assert!(
         avro_value.validate(&writer_schema),
         "value is valid for schema",
     );
-    let datum = crate::to_avro_datum(&writer_schema, avro_value)?;
+    let datum = to_avro_datum(&writer_schema, avro_value)?;
     let mut x = &datum[..];
     let reader_schema = Schema::parse_str(reader_schema)?;
-    let deser_value = crate::from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
+    let deser_value = from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
     match deser_value {
         types::Value::Record(fields) => {
             assert_eq!(fields.len(), 1);
@@ -364,15 +364,15 @@ fn test_avro_3786_deserialize_union_with_different_enum_order_defined_in_record_
     let foo1 = Foo {
         bar_parent: Some(BarParent { bar: Bar::Bar1 }),
     };
-    let avro_value = crate::to_value(foo1)?;
+    let avro_value = to_value(foo1)?;
     assert!(
         avro_value.validate(&writer_schema),
         "value is valid for schema",
     );
-    let datum = crate::to_avro_datum(&writer_schema, avro_value)?;
+    let datum = to_avro_datum(&writer_schema, avro_value)?;
     let mut x = &datum[..];
     let reader_schema = Schema::parse_str(reader_schema)?;
-    let deser_value = crate::from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
+    let deser_value = from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
     match deser_value {
         types::Value::Record(fields) => {
             assert_eq!(fields.len(), 1);
@@ -477,15 +477,15 @@ fn test_avro_3786_deserialize_union_with_different_enum_order_defined_in_record_
     let foo1 = Foo {
         bar_parent: Some(BarParent { bar: Bar::Bar1 }),
     };
-    let avro_value = crate::to_value(foo1)?;
+    let avro_value = to_value(foo1)?;
     assert!(
         avro_value.validate(&writer_schema),
         "value is valid for schema",
     );
-    let datum = crate::to_avro_datum(&writer_schema, avro_value)?;
+    let datum = to_avro_datum(&writer_schema, avro_value)?;
     let mut x = &datum[..];
     let reader_schema = Schema::parse_str(reader_schema)?;
-    let deser_value = crate::from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
+    let deser_value = from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
     match deser_value {
         types::Value::Record(fields) => {
             assert_eq!(fields.len(), 1);
@@ -590,15 +590,15 @@ fn deserialize_union_with_different_enum_order_defined_in_record() -> TestResult
     let foo1 = Foo {
         bar_parent: Some(BarParent { bar: Bar::Bar2 }),
     };
-    let avro_value = crate::to_value(foo1)?;
+    let avro_value = to_value(foo1)?;
     assert!(
         avro_value.validate(&writer_schema),
         "value is valid for schema",
     );
-    let datum = crate::to_avro_datum(&writer_schema, avro_value)?;
+    let datum = to_avro_datum(&writer_schema, avro_value)?;
     let mut x = &datum[..];
     let reader_schema = Schema::parse_str(reader_schema)?;
-    let deser_value = crate::from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
+    let deser_value = from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
     match deser_value {
         types::Value::Record(fields) => {
             assert_eq!(fields.len(), 1);
@@ -864,15 +864,15 @@ fn deserialize_union_with_record_with_enum_defined_inline_reader_has_different_i
             defined_in_record: DefinedInRecord::Val1,
         }),
     };
-    let avro_value = crate::to_value(foo1)?;
+    let avro_value = to_value(foo1)?;
     assert!(
         avro_value.validate(&writer_schema),
         "value is valid for schema",
     );
-    let datum = crate::to_avro_datum(&writer_schema, avro_value)?;
+    let datum = to_avro_datum(&writer_schema, avro_value)?;
     let mut x = &datum[..];
     let reader_schema = Schema::parse_str(reader_schema)?;
-    let deser_value = crate::from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
+    let deser_value = from_avro_datum(&writer_schema, &mut x, Some(&reader_schema))?;
     match deser_value {
         types::Value::Record(fields) => {
             assert_eq!(fields.len(), 3);
diff --git a/lang/rust/avro/tests/big_decimal.rs b/lang/rust/avro/tests/big_decimal.rs
new file mode 100644
index 000000000..b05247103
--- /dev/null
+++ b/lang/rust/avro/tests/big_decimal.rs
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use apache_avro::BigDecimal;
+
+#[test]
+fn avro_3948_use_apache_avro_big_decimal() {
+    let _ = BigDecimal::from(1234567890123456789_i64);
+}

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic