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

Santiago Fraire Willemoes updated AVRO-4055:
--------------------------------------------
    Description: 
*Current state*
Rust parses the following schema correctly, without raising any errors:

{code}
{
  "type": "record",
  "name": "SampleSchema",
  "fields": [
    {
      "name": "order",
      "type": "record",
      "fields": [
        {
          "name": "order_number",
          "type": ["null", "string"],
          "default": null
        },
        { "name": "order_date", "type": "string" }
      ]
    }
  ]
}
{code}

*Desired state*
Rust returns an error with the previous schema

*Correct schema sample*

Sample code:
{code}
use apache_avro::Schema;

let raw_schema = r#"
{
  "type": "record",
  "name": "SampleSchema",
  "fields": [
    {
      "name": "order",
      "type": "record",
      "fields": [
        {
          "name": "order_number",
          "type": ["null", "string"],
          "default": null
        },
        { "name": "order_date", "type": "string" }
      ]
    }
  ]
}
"#;

// if the schema is not valid, this function will return an error
let schema = Schema::parse_str(raw_schema).unwrap();

// schemas can be printed for debugging
println!("{:?}", schema);
{code}

Why is this important? Other tools like in Java are not able to parse this 
schema, making compatibility between different languages harder.

We've had issues using `avro-tools` to build the jars.

I can try to fix it, let me know if you want me to send a PR.

Regards


  was:
Parsing a schema like this should be invalid on rust, but rust parses the 
schema without raising errors:

{code}
{
  "type": "record",
  "name": "SampleSchema",
  "fields": [
    {
      "name": "order",
      "type": "record",
      "fields": [
        {
          "name": "order_number",
          "type": ["null", "string"],
          "default": null
        },
        { "name": "order_date", "type": "string" }
      ]
    }
  ]
}
{code}

Sample code:
{code}
use apache_avro::Schema;

let raw_schema = r#"
{
  "type": "record",
  "name": "SampleSchema",
  "fields": [
    {
      "name": "order",
      "type": "record",
      "fields": [
        {
          "name": "order_number",
          "type": ["null", "string"],
          "default": null
        },
        { "name": "order_date", "type": "string" }
      ]
    }
  ]
}
"#;

// if the schema is not valid, this function will return an error
let schema = Schema::parse_str(raw_schema).unwrap();

// schemas can be printed for debugging
println!("{:?}", schema);
{code}

Why is this important? Other tools like in Java are not able to parse this 
schema, making compatibility between different languages harder.

We've had issues using `avro-tools` to build the jars.

I can try to fix it, let me know if you want me to send a PR.

Regards



> [rust] schema parsing invalid with nested records
> -------------------------------------------------
>
>                 Key: AVRO-4055
>                 URL: https://issues.apache.org/jira/browse/AVRO-4055
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: rust
>            Reporter: Santiago Fraire Willemoes
>            Priority: Major
>              Labels: rust
>
> *Current state*
> Rust parses the following schema correctly, without raising any errors:
> {code}
> {
>   "type": "record",
>   "name": "SampleSchema",
>   "fields": [
>     {
>       "name": "order",
>       "type": "record",
>       "fields": [
>         {
>           "name": "order_number",
>           "type": ["null", "string"],
>           "default": null
>         },
>         { "name": "order_date", "type": "string" }
>       ]
>     }
>   ]
> }
> {code}
> *Desired state*
> Rust returns an error with the previous schema
> *Correct schema sample*
> Sample code:
> {code}
> use apache_avro::Schema;
> let raw_schema = r#"
> {
>   "type": "record",
>   "name": "SampleSchema",
>   "fields": [
>     {
>       "name": "order",
>       "type": "record",
>       "fields": [
>         {
>           "name": "order_number",
>           "type": ["null", "string"],
>           "default": null
>         },
>         { "name": "order_date", "type": "string" }
>       ]
>     }
>   ]
> }
> "#;
> // if the schema is not valid, this function will return an error
> let schema = Schema::parse_str(raw_schema).unwrap();
> // schemas can be printed for debugging
> println!("{:?}", schema);
> {code}
> Why is this important? Other tools like in Java are not able to parse this 
> schema, making compatibility between different languages harder.
> We've had issues using `avro-tools` to build the jars.
> I can try to fix it, let me know if you want me to send a PR.
> Regards



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

Reply via email to