John McClean created AVRO-1912:
----------------------------------
Summary: C++ Resolving Decoding doesn't work if element removed
from record in array.
Key: AVRO-1912
URL: https://issues.apache.org/jira/browse/AVRO-1912
Project: Avro
Issue Type: Bug
Reporter: John McClean
Writer schema:
{code}
{
"type": "record",
"name": "TestRecord",
"fields": [
{
"name": "array",
"type": {
"type": "array",
"items": {
"name": "item",
"type": "record",
"fields": [
{ "name": "A", "type": "string" },
{ "name": "B", "type": "string", "default": "foo" }
]
}
}
}
]
}
{code}
Reader schema:
{code}
{
"type": "record",
"name": "TestRecord",
"fields": [
{
"name": "array",
"type": {
"type": "array",
"items": {
"name": "item",
"type": "record",
"fields": [
{ "name": "A", "type": "string" }
]
}
}
}
]
}
{code}
Data is:
{code}
{
"array": [
{
"A": "",
"B": ""
}
]
}
{code}
The following code fails with an exception “Expected: Repeater got String”. The
equivalent java code works fine on the same schema and data.
{code}
auto decoder = avro::resolvingDecoder(writerSchema,
readerSchema,
avro::jsonDecoder(writerSchema));
strinstream ss = loadData();
auto_ptr<avro::InputStream> in = avro::istreamInputStream(ss);
decoder->init(*in);
auto record = reader::TestRecord();
decode(*decoder, record);
{code}
I stepped through the code and what seems to be happening is that the code is
treating “A” and “B” as distinct elements in the array, as if the array had two
elements rather than one.
I'm not sure how to go about fixing this. Any pointers would be appreciated. (I
don't think it's my C++ test code. It works fine if the record above isn't in
an array.)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)