I'm using Kafka with Avro messages. One of my fields is defined like this:
{
"name": "a_number",
"type": "bytes",
"logicalType": "decimal",
"precision": 4,
"scale": 4
}
Using the Avro console consumer, I see a message like this:
{"a_number": "\t\u0000°"}
Which I expect to equal 59
.
Supposedly, the bytearray should be the twos-compliment of the number. I've tried using Python's struct
module to decode it, but the values I get don't make any sense:
bs = '\t\u0000°'.encode('utf8') # b'\t\x00\xc2\xb0'
struct.unpack('>l', bs)[0] / 1e4 # 15104.4784
How can I validate the message? Can I decode the string somehow, or has the Avro console consumer corrupted it?