You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Vegard Solberg (Jira)" <ji...@apache.org> on 2021/09/27 13:38:00 UTC
[jira] [Updated] (AVRO-3218) Pass LogicalType to BytesDecimalSchema
in Python
[ https://issues.apache.org/jira/browse/AVRO-3218?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vegard Solberg updated AVRO-3218:
---------------------------------
Attachment: issue.py
Component/s: python
Language: Python
Affects Version/s: 1.10.2
Description:
I get an error when parsing a schema which contains a field with `logicalType=decimal` in Python. Spesifically, I am using avro.schema.parse() on a schema which have a field on the following format:
{code:java}
{ "name": "myField", "type": [ "null", { "type": "bytes", "logicalType": "decimal", "precision": 12, "scale": 2 } ]}
{code}
Eventually, make_bytes_decimal_schema() is called. At this point, the variable other_props looks like this (and is fine):
{code:java}
other_props = {'logicalType': 'decimal', 'precision': 12, 'scale': 2}{code}
Unlike the other logical types, the variable other_props is not passed on to BytesDecimalSchema. The result is that the resulting logical_schemais missing the key-value pair 'logicalType': 'decimal'. This blocks me from writing to a kafka topic, because the schema is parsed incorrectly. The resulting field looks like this:
{code:java}
{"type": ["null", {"type": "bytes", "precision": 12, "scale": 2}], "name": "myField"}
{code}
The suggested fix is to simply pass other_props as an argument into BytesDecimalSchema()
Environment:
I am using avro 1.10.2. Example file to reproduce the problem.
[^issue.py]
Summary: Pass LogicalType to BytesDecimalSchema in Python (was: LogicalType )
> Pass LogicalType to BytesDecimalSchema in Python
> ------------------------------------------------
>
> Key: AVRO-3218
> URL: https://issues.apache.org/jira/browse/AVRO-3218
> Project: Apache Avro
> Issue Type: Bug
> Components: python
> Affects Versions: 1.10.2
> Environment: I am using avro 1.10.2. Example file to reproduce the problem.
> [^issue.py]
> Reporter: Vegard Solberg
> Priority: Major
> Attachments: issue.py
>
>
> I get an error when parsing a schema which contains a field with `logicalType=decimal` in Python. Spesifically, I am using avro.schema.parse() on a schema which have a field on the following format:
> {code:java}
> { "name": "myField", "type": [ "null", { "type": "bytes", "logicalType": "decimal", "precision": 12, "scale": 2 } ]}
> {code}
> Eventually, make_bytes_decimal_schema() is called. At this point, the variable other_props looks like this (and is fine):
>
> {code:java}
> other_props = {'logicalType': 'decimal', 'precision': 12, 'scale': 2}{code}
>
> Unlike the other logical types, the variable other_props is not passed on to BytesDecimalSchema. The result is that the resulting logical_schemais missing the key-value pair 'logicalType': 'decimal'. This blocks me from writing to a kafka topic, because the schema is parsed incorrectly. The resulting field looks like this:
> {code:java}
> {"type": ["null", {"type": "bytes", "precision": 12, "scale": 2}], "name": "myField"}
> {code}
>
> The suggested fix is to simply pass other_props as an argument into BytesDecimalSchema()
--
This message was sent by Atlassian Jira
(v8.3.4#803005)