Open
Description
I have the following snippet
import io
from decimal import Decimal
import fastavro
schema = {
"type": "record",
"name": "User",
"namespace": "com.example",
"fields": [
{
"name": "id",
"type": "int"
},
{
"name": "paid",
"type": {
"type": "bytes",
"scale": 2,
"precision": 15,
"logicalType": "decimal"
},
"default": "\u0000"
},
{
"name": "age",
"type": ["null", "int"],
"default": None
}
]
}
# works
records = [
{"id": 1, "age": 30, "paid": Decimal("0.00")},
{"id": 2, "age": None, "paid": Decimal("0.01")},
]
fastavro.writer(io.BytesIO(), schema, records)
# throws exception
records = [
{"id": 1, "age": 30},
]
fastavro.writer(io.BytesIO(), schema, records)
fastavro is successful writing records when paid is defined, however i receive an error when trying to write a record when paid is not defined, hoping to use the default value specified in the schema. Please can anyone advise if I am doing something incorrect or have encountered an unexpected issue? I am using fastavro==1.9.7
Many thanks
Metadata
Metadata
Assignees
Labels
No labels