We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Reproduce with an example:
use avro_rs::Schema; fn main() { // let raw = fs::read_to_string("/Users/bgabor8/git/dqc/data-benchmark/trans-3.1.avsc").unwrap(); // let schema = Schema::parse_str(&raw).unwrap(); // println!("{:?}", schema); let raw = r#" { "name": "Data", "type": "record", "fields": [ { "name": "sources", "type": { "type": "array", "items": [ { "name": "Url", "type": "record", "fields": [{ "name": "url", "type": "string" }] }, { "name": "Source", "type": "record", "fields": [{ "name": "data", "type": "string"}] } ] } } ] } "#; Schema::parse_str(raw).unwrap(); }
value: ParseSchemaError("Unions cannot contain duplicate types")
For reference the python avro behaviour (demonstrating that the construction is valid):
import json from io import BytesIO from avro.io import BinaryEncoder, DatumWriter, DatumReader, BinaryDecoder from avro.schema import parse json_schema_raw = { "name": "Data", "type": "record", "fields": [ { "name": "sources", "type": { "type": "array", "items": [ {"name": "Url", "type": "record", "fields": [{"name": "url", "type": "string"}]}, {"name": "Source", "type": "record", "fields": [{"name": "data", "type": "string"}]}, ], }, } ], } schema = parse(json.dumps(json_schema_raw)) writer = DatumWriter() with BytesIO() as serialized_binary: binary_encoder = BinaryEncoder(serialized_binary) writer.write_record(schema, {"sources": [{"url": "a"}, {"data": "b"}]}, binary_encoder) raw = serialized_binary.getvalue() print(raw) reader = DatumReader() with BytesIO(raw) as binary_input: binary_decoder = BinaryDecoder(binary_input) record = reader.read_record(schema, schema, binary_decoder) print(record)
b'\x04\x00\x02a\x02\x02b\x00' {'sources': [{'url': 'a'}, {'data': 'b'}]}
The issue seems to be here https://github.com/flavray/avro-rs/blob/master/src/schema.rs#L330, while iterating through the schema records the SchemaKind::from(schema) identifies both Url and Source from above as Schema::Null, hence the duplicate error.
SchemaKind::from(schema)
Url
Source
Schema::Null
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Reproduce with an example:
value: ParseSchemaError("Unions cannot contain duplicate types")
For reference the python avro behaviour (demonstrating that the construction is valid):
The issue seems to be here https://github.com/flavray/avro-rs/blob/master/src/schema.rs#L330, while iterating through the schema records the
SchemaKind::from(schema)
identifies bothUrl
andSource
from above asSchema::Null
, hence the duplicate error.The text was updated successfully, but these errors were encountered: