[ 
https://issues.apache.org/jira/browse/AVRO-3901?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Simon Gittins updated AVRO-3901:
--------------------------------
    Description: 
Want to be able to serde to/from an enum containing structs for a union schema 
containing record(s):

{code:json}
{
  "name": "C",
  "type": "record",
  "fields": [
...
    \{"name": "field_union", "type": ["A", "B"]},
...
  ]
}
{code}

With code like:

struct A \{...}
struct B \{...}

#[serde(untagged)]
enum UnionAB \{ A(A), B(B)}

struct C {
  ...
  field_union: UnionAB,
  ...
}

Likewise, want to be able to serde where the schema includes null:

{code:json}
{
  "name": "E",
  "type": "record",
  "fields": [
    ...
    \{"name": "field_union", "type": ["A", "null", "B"]},
    ...
  ]
}
{code}

#[serde(untagged)]
enum UnionANoneB {
    A(A),
    None,
    B(B),
}

  was:
Want to be able to serde to/from an enum containing structs for a union schema 
containing record(s):

{{{}}
{{  "name": "C",}}
{{  "type": "record",}}
{{  "fields": [}}
{{...}}
{{    \{"name": "field_union", "type": ["A", "B"]},}}
{{...}}
{{  ]}}
{{}}}

With code like:

{{struct A \{...}}}
{{struct B \{...}}}

{{#[serde(untagged)]}}
{{{}enum UnionAB \{ A(A), B(B)}{}}}{{{}struct C {{}}}
{{  ...}}
{{  field_union: UnionAB,}}
{{  ...}}
{{}}}

{{Likewise, want to be able to serde where the schema includes null:}}
{{{}}
{{  "name": "E",}}
{{  "type": "record",}}
{{  "fields": [}}
{{    ...}}
{{    \{"name": "field_union", "type": ["A", "null", "B"]},}}
{{    ...}}
{{  ]}}
{{}}}

{{#[serde(untagged)]}}
{{enum UnionANoneB {}}
{{    A(A),}}
{{    None,}}
{{    B(B),}}
{{}}}


> [Rust] Better serde union support
> ---------------------------------
>
>                 Key: AVRO-3901
>                 URL: https://issues.apache.org/jira/browse/AVRO-3901
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: rust
>    Affects Versions: 1.11.3
>            Reporter: Simon Gittins
>            Priority: Major
>
> Want to be able to serde to/from an enum containing structs for a union 
> schema containing record(s):
> {code:json}
> {
>   "name": "C",
>   "type": "record",
>   "fields": [
> ...
>     \{"name": "field_union", "type": ["A", "B"]},
> ...
>   ]
> }
> {code}
> With code like:
> struct A \{...}
> struct B \{...}
> #[serde(untagged)]
> enum UnionAB \{ A(A), B(B)}
> struct C {
>   ...
>   field_union: UnionAB,
>   ...
> }
> Likewise, want to be able to serde where the schema includes null:
> {code:json}
> {
>   "name": "E",
>   "type": "record",
>   "fields": [
>     ...
>     \{"name": "field_union", "type": ["A", "null", "B"]},
>     ...
>   ]
> }
> {code}
> #[serde(untagged)]
> enum UnionANoneB {
>     A(A),
>     None,
>     B(B),
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to