Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems Value::Union never used, please mark it as deprecated #12

Open
safinaskar opened this issue Dec 11, 2021 · 0 comments
Open

It seems Value::Union never used, please mark it as deprecated #12

safinaskar opened this issue Dec 11, 2021 · 0 comments

Comments

@safinaskar
Copy link

Hi. I'm unable to understand why we have Value::Union. I attempted to run this code:

use anyhow::Error;
use avrow::{Schema, Writer};
use std::str::FromStr;

fn main() -> Result<(), Error> {
    let schema = Schema::from_str(r##"{
        "type": "record",
        "name": "LongList",
        "aliases": ["LinkedLongs"],
        "fields" : [
          {"name": "value", "type": "long"},
          {"name": "next", "type": ["null", "LongList"]}
        ]
      }"##)?;
    let mut writer = Writer::new(&schema, std::io::stdout())?;
    let mut r = avrow::Record::new("LongList");
    r.insert("value", 2i64);
    r.insert("next", avrow::Value::Union(Box::new(avrow::Value::Null)));
    let res = writer.write(avrow::Value::Record(r))?;
    Ok(())
}

...and I got error Error: Value schema not found in union.
Then I tried this code (note line "XXX"):

use anyhow::Error;
use avrow::{Schema, Writer};
use std::str::FromStr;

fn main() -> Result<(), Error> {
    let schema = Schema::from_str(r##"{
        "type": "record",
        "name": "LongList",
        "aliases": ["LinkedLongs"],
        "fields" : [
          {"name": "value", "type": "long"},
          {"name": "next", "type": ["null", "LongList"]}
        ]
      }"##)?;
    let mut writer = Writer::new(&schema, std::io::stdout())?;
    let mut r = avrow::Record::new("LongList");
    r.insert("value", 2i64);
    r.insert("next", avrow::Value::Null); // XXX
    let res = writer.write(avrow::Value::Record(r))?;
    Ok(())
}

...and this time I got no error.

So, it seems from my experiments, that Value::Union is not used at all in avrow. Am I right?

I grepped avrow source code and now I even more sure that Value::Union is not used. All code samples I found was trivial, Value::Union is never constructed.

So, please, mark it as deprecated to make docs more clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant