You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/11/30 08:59:38 UTC
[avro] branch avro-3678-float-to-doable created (now 6457dbb25)
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a change to branch avro-3678-float-to-doable
in repository https://gitbox.apache.org/repos/asf/avro.git
at 6457dbb25 AVRO-3678: [Rust] Support writing float value to field defined as double
This branch includes the following new commits:
new 6457dbb25 AVRO-3678: [Rust] Support writing float value to field defined as double
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[avro] 01/01: AVRO-3678: [Rust] Support writing float value to field defined as double
Posted by mg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch avro-3678-float-to-doable
in repository https://gitbox.apache.org/repos/asf/avro.git
commit 6457dbb25c84dba545d390992c82772d406479e3
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Wed Nov 30 10:58:12 2022 +0200
AVRO-3678: [Rust] Support writing float value to field defined as double
Originally contributed by @shaeqahmed with #1985
Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
lang/rust/avro/src/types.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lang/rust/avro/src/types.rs b/lang/rust/avro/src/types.rs
index 688af8eeb..9ee6b7b2d 100644
--- a/lang/rust/avro/src/types.rs
+++ b/lang/rust/avro/src/types.rs
@@ -403,6 +403,7 @@ impl Value {
(&Value::Duration(_), &Schema::Duration) => None,
(&Value::Uuid(_), &Schema::Uuid) => None,
(&Value::Float(_), &Schema::Float) => None,
+ (&Value::Float(_), &Schema::Double) => None,
(&Value::Double(_), &Schema::Double) => None,
(&Value::Bytes(_), &Schema::Bytes) => None,
(&Value::Bytes(_), &Schema::Decimal { .. }) => None,
@@ -1011,6 +1012,9 @@ mod tests {
fn validate() {
let value_schema_valid = vec![
(Value::Int(42), Schema::Int, true, ""),
+ (Value::Int(43), Schema::Long, true, ""),
+ (Value::Float(43.2), Schema::Float, true, ""),
+ (Value::Float(45.9), Schema::Double, true, ""),
(
Value::Int(42),
Schema::Boolean,
@@ -1565,6 +1569,12 @@ Field with name '"b"' is not a member of the map items"#,
assert!(value.resolve(&Schema::TimestampMicros).is_err());
}
+ #[test]
+ fn avro_3678_resolve_float_to_double() {
+ let value = Value::Float(2345.1);
+ assert!(value.resolve(&Schema::Double).is_ok());
+ }
+
#[test]
fn test_avro_3621_resolve_to_nullable_union() {
let schema = Schema::parse_str(