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/07/25 08:16:45 UTC
[avro] branch branch-1.11 updated: AVRO-3585: Add support for encoding Value::String as Schema::Uuid (#1778)
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/branch-1.11 by this push:
new fa3d83ae9 AVRO-3585: Add support for encoding Value::String as Schema::Uuid (#1778)
fa3d83ae9 is described below
commit fa3d83ae9502341c321edbe368552badd26af4ac
Author: Rik Heijdens <Ri...@users.noreply.github.com>
AuthorDate: Mon Jul 25 10:16:09 2022 +0200
AVRO-3585: Add support for encoding Value::String as Schema::Uuid (#1778)
* AVRO-3585: Add test-case to confirm UUID handling
Added a test-case to confirm encoding UUIDs that are provided as
Value::String works as expected.
* AVRO-3585: Add Uuid as a supported encoding
Added Schema::Uuid as supported encoding for Value::String.
In some cases Uuids may be presented as a Value::String to the Avro
encoder, previously, the encoder would reject these values. This has
been fixed by this commit.
* AVRO-3585: Simplify match statement
Removed a duplicate branch for matching Schema::Uuid by collapsing
it into the branch for matching Schema::String.
Co-authored-by: gabriel <ga...@lithic.com>
(cherry picked from commit 945820a9ce5a4ad67fb9a9cdacbddbaacfd2e5db)
---
lang/rust/avro/src/encode.rs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lang/rust/avro/src/encode.rs b/lang/rust/avro/src/encode.rs
index afb3e2964..0d40a498f 100644
--- a/lang/rust/avro/src/encode.rs
+++ b/lang/rust/avro/src/encode.rs
@@ -123,7 +123,7 @@ pub(crate) fn encode_internal<S: Borrow<Schema>>(
}
},
Value::String(s) => match *schema {
- Schema::String => {
+ Schema::String | Schema::Uuid => {
encode_bytes(s, buffer);
}
Schema::Enum { ref symbols, .. } => {
@@ -827,4 +827,14 @@ pub(crate) mod tests {
.expect(&success(&outer_record_variation_3, &schema));
assert!(!buf.is_empty());
}
+
+ #[test]
+ fn test_avro_3585_encode_uuids() {
+ let value = Value::String(String::from("00000000-0000-0000-0000-000000000000"));
+ let schema = Schema::Uuid;
+ let mut buffer = Vec::new();
+ let encoded = encode(&value, &schema, &mut buffer);
+ assert!(encoded.is_ok());
+ assert!(!buffer.is_empty());
+ }
}