You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "markfarnan (via GitHub)" <gi...@apache.org> on 2023/03/13 19:50:04 UTC

[GitHub] [avro] markfarnan commented on pull request #1921: AVRO-3646: serde for enum with mixed variants

markfarnan commented on PR #1921:
URL: https://github.com/apache/avro/pull/1921#issuecomment-1466859552

   Seems like AVRO-3695 should be addressed in this issue.  (see https://github.com/apache/avro/pull/2035)
   
   However I just tested it against Master + AVRO-3631 and it does not address the problem. 
   
   This is my last blocking issue for using Rust for our industry protocol, so hoping it can be looked at.   @martin-g  ?
   
   I've created what is probably a 'Hack' fix that addresses the issue for me.  But honestly I'm not sure what i'm doing here, so it likley breaks other stuff.   (So I havn't made a PR, just added here for your info)
   
   ser.rs
   `    fn serialize_newtype_variant<T: ?Sized>(
           self,
           _enum_name: &'static str,
           index: u32,
           _variant: &'static str,
           value: &T,
       ) -> Result<Self::Ok, Self::Error>
       where
           T: Serialize,
       {
           let serialized = value.serialize(self)?;
           let _idx = match serialized {
               // assumes that the Null variant is always the first one, as in Avro's Union
               Value::Null => 0,
               _ => index,
           };
           // Ok(Value::Record(vec![
           //     ("type".to_owned(), Value::Enum(index, variant.to_owned())),
           //     ("value".to_owned(), Value::Union(idx, Box::new(serialized))),
           // ]))
   
           Ok(Value::Union(index, Box::new(serialized)))
       }`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org