Skip to content

Schema default value is not taken into account #53

@przemek-airslate

Description

@przemek-airslate

Code snipped below doesn't work.
$dataWriter->append(...); seems to not process default value.

Isn't it expected to contain "married" field with "null" value in encoded string? It throws AvroIOTypeException instead

$schema = <<<_JSON
{
 "name":"member",
 "type":"record",
 "fields":[
    {"name": "member_id", "type": "int"},
    {"name": "member_name", "type": "string"},
    {"name": "married", "type": ["null","boolean"], "default": null}
 ]
}
_JSON;

$jose = [
    'member_id' => 1392,
    'member_name' => 'Jose',
    //    'married' => true
];

$writerSchema = AvroSchema::parse($schema);
$io = new AvroStringIO();
$writer = new AvroIODatumWriter($writerSchema);
$dataWriter = new AvroDataIOWriter($io, $writer, $writerSchema);
$dataWriter->append($jose);
$dataWriter->close();
echo $binaryString = $io->string();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions