You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Josua Stingelin <jo...@hotmail.com> on 2023/10/23 16:30:48 UTC

[rust crate apache_avro] Alias and Serde Serialization

Hei Guys,

-- off topic
I hope this is the correct mailing list. I tried to send on user list first but
the mail bounced because I haven't subscribed the mailing list. However, I
didn't figure out where I can subscribe =/
--

This concerns the rust crate apache-avro.


Does anyone know if it's possible, to use type aliases with serde serialization?

When trying to serialize an object using `writer.append_ser` I get the following
error:

  called `Result::unwrap()` on an `Err` value: There is no entry for date in the lookup table: {"name": String("Great Meeting"), "time": Union(0, Null)}.

Renaming `time` to `date` would fix the issue, but the goal is to simulate
renaming a propetry as part of a schema evolution.


With the following schema:

  const RAW_SCHEMA_V2 : &str = r#"
  {
      "type": "record",
      "name": "Conference",
      "namespace": "sth",
      "fields": [
          {"type": "string", "name": "name"},
          {"type": ["null", "long"], "name": "date", "aliases" : [ "time" ]},
      ]
  }"#;


And the struct:

  #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
  pub struct Conference {
      pub name: String,
      pub time: Option<i64>,
  }


Thank you for any hint on what I'm doing wrong =)
Josua

Re: [rust crate apache_avro] Alias and Serde Serialization

Posted by Martin Grigorov <mg...@apache.org>.
Hi Josua,

You can see our complete discussion at
https://lists.apache.org/thread/jtx7520hq2bd98ksqsbg2nll94htjf40
There is a "Subscribe to list" button on the left side of
https://lists.apache.org/list.html?dev@avro.apache.org

Thank you for the test case! I've added it to the test suite!

Regards,
Martin

On Wed, Oct 25, 2023 at 12:32 AM Josua Stingelin <jo...@hotmail.com>
wrote:

> Hei Martin
>
> Thanks for getting back to me!
>
> > I just realized that you are not subscribed to the mailing list and you
> > didn't receive my earlier responses.
> Jup didn't find out how to register ':)
>
>
> > Please provide a complete test case that reproduces the problem and
> > either open a Pull Request or paste it here.
> > Then we’ll debug it and provide a fix.
> I've attached a minimal working example. Let me know if it help.
>
> Cheers,
> Josua
>

[rust crate apache_avro] Alias and Serde Serialization

Posted by Josua Stingelin <jo...@hotmail.com>.
Hei Martin

Thanks for getting back to me!

> I just realized that you are not subscribed to the mailing list and you
> didn't receive my earlier responses.
Jup didn't find out how to register ':)


> Please provide a complete test case that reproduces the problem and
> either open a Pull Request or paste it here.
> Then we’ll debug it and provide a fix.
I've attached a minimal working example. Let me know if it help.

Cheers,
Josua

Re: [rust crate apache_avro] Alias and Serde Serialization

Posted by Martin Grigorov <mg...@apache.org>.
Hi Josua,

I just realized that you are not subscribed to the mailing list and you
didn't receive my earlier responses.
Please see below.

Martin

On Tue, Oct 24, 2023 at 11:41 AM Martin Grigorov <mg...@apache.org>
wrote:

> https://issues.apache.org/jira/browse/AVRO-3894
> https://github.com/apache/avro/pull/2566
>
> On Mon, Oct 23, 2023 at 8:54 PM Martin Grigorov <mg...@apache.org>
> wrote:
>
>> Hi,
>>
>> Please provide a complete test case that reproduces the problem and
>> either open a Pull Request or paste it here.
>> Then we’ll debug it and provide a fix.
>>
>> Regards,
>> Martin
>>
>> On Mon, 23 Oct 2023 at 20:03, Josua Stingelin <jo...@hotmail.com>
>> wrote:
>>
>>> Hei Guys,
>>>
>>> -- off topic
>>> I hope this is the correct mailing list. I tried to send on user list
>>> first but
>>> the mail bounced because I haven't subscribed the mailing list. However,
>>> I
>>> didn't figure out where I can subscribe =/
>>> --
>>>
>>> This concerns the rust crate apache-avro.
>>>
>>>
>>> Does anyone know if it's possible, to use type aliases with serde
>>> serialization?
>>>
>>> When trying to serialize an object using `writer.append_ser` I get the
>>> following
>>> error:
>>>
>>>   called `Result::unwrap()` on an `Err` value: There is no entry for
>>> date in the lookup table: {"name": String("Great Meeting"), "time":
>>> Union(0, Null)}.
>>>
>>> Renaming `time` to `date` would fix the issue, but the goal is to
>>> simulate
>>> renaming a propetry as part of a schema evolution.
>>>
>>>
>>> With the following schema:
>>>
>>>   const RAW_SCHEMA_V2 : &str = r#"
>>>   {
>>>       "type": "record",
>>>       "name": "Conference",
>>>       "namespace": "sth",
>>>       "fields": [
>>>           {"type": "string", "name": "name"},
>>>           {"type": ["null", "long"], "name": "date", "aliases" : [
>>> "time" ]},
>>>       ]
>>>   }"#;
>>>
>>>
>>> And the struct:
>>>
>>>   #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
>>>   pub struct Conference {
>>>       pub name: String,
>>>       pub time: Option<i64>,
>>>   }
>>>
>>>
>>> Thank you for any hint on what I'm doing wrong =)
>>> Josua
>>>
>>

Re: [rust crate apache_avro] Alias and Serde Serialization

Posted by Martin Grigorov <mg...@apache.org>.
https://issues.apache.org/jira/browse/AVRO-3894
https://github.com/apache/avro/pull/2566

On Mon, Oct 23, 2023 at 8:54 PM Martin Grigorov <mg...@apache.org>
wrote:

> Hi,
>
> Please provide a complete test case that reproduces the problem and either
> open a Pull Request or paste it here.
> Then we’ll debug it and provide a fix.
>
> Regards,
> Martin
>
> On Mon, 23 Oct 2023 at 20:03, Josua Stingelin <jo...@hotmail.com> wrote:
>
>> Hei Guys,
>>
>> -- off topic
>> I hope this is the correct mailing list. I tried to send on user list
>> first but
>> the mail bounced because I haven't subscribed the mailing list. However, I
>> didn't figure out where I can subscribe =/
>> --
>>
>> This concerns the rust crate apache-avro.
>>
>>
>> Does anyone know if it's possible, to use type aliases with serde
>> serialization?
>>
>> When trying to serialize an object using `writer.append_ser` I get the
>> following
>> error:
>>
>>   called `Result::unwrap()` on an `Err` value: There is no entry for date
>> in the lookup table: {"name": String("Great Meeting"), "time": Union(0,
>> Null)}.
>>
>> Renaming `time` to `date` would fix the issue, but the goal is to simulate
>> renaming a propetry as part of a schema evolution.
>>
>>
>> With the following schema:
>>
>>   const RAW_SCHEMA_V2 : &str = r#"
>>   {
>>       "type": "record",
>>       "name": "Conference",
>>       "namespace": "sth",
>>       "fields": [
>>           {"type": "string", "name": "name"},
>>           {"type": ["null", "long"], "name": "date", "aliases" : [ "time"
>> ]},
>>       ]
>>   }"#;
>>
>>
>> And the struct:
>>
>>   #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
>>   pub struct Conference {
>>       pub name: String,
>>       pub time: Option<i64>,
>>   }
>>
>>
>> Thank you for any hint on what I'm doing wrong =)
>> Josua
>>
>

Re: [rust crate apache_avro] Alias and Serde Serialization

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Please provide a complete test case that reproduces the problem and either
open a Pull Request or paste it here.
Then we’ll debug it and provide a fix.

Regards,
Martin

On Mon, 23 Oct 2023 at 20:03, Josua Stingelin <jo...@hotmail.com> wrote:

> Hei Guys,
>
> -- off topic
> I hope this is the correct mailing list. I tried to send on user list
> first but
> the mail bounced because I haven't subscribed the mailing list. However, I
> didn't figure out where I can subscribe =/
> --
>
> This concerns the rust crate apache-avro.
>
>
> Does anyone know if it's possible, to use type aliases with serde
> serialization?
>
> When trying to serialize an object using `writer.append_ser` I get the
> following
> error:
>
>   called `Result::unwrap()` on an `Err` value: There is no entry for date
> in the lookup table: {"name": String("Great Meeting"), "time": Union(0,
> Null)}.
>
> Renaming `time` to `date` would fix the issue, but the goal is to simulate
> renaming a propetry as part of a schema evolution.
>
>
> With the following schema:
>
>   const RAW_SCHEMA_V2 : &str = r#"
>   {
>       "type": "record",
>       "name": "Conference",
>       "namespace": "sth",
>       "fields": [
>           {"type": "string", "name": "name"},
>           {"type": ["null", "long"], "name": "date", "aliases" : [ "time"
> ]},
>       ]
>   }"#;
>
>
> And the struct:
>
>   #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
>   pub struct Conference {
>       pub name: String,
>       pub time: Option<i64>,
>   }
>
>
> Thank you for any hint on what I'm doing wrong =)
> Josua
>