ChrisRx/quickavro

Segmentation fault when using float + union type

luup2k opened this issue · 2 comments

Test Case 1 on Python 3.4.5:
Union data type: {"name": "age", "type": [ "float", "null" ] }

records = [{"name": "Dark Larry", "age": 1108311.1},]
type(records[0]['age']) #float class 
import quickavro

with quickavro.FileWriter("example.avro") as writer:
	writer.schema = {
		"type": "record",
		"name": "Person",
		"fields": [
			{"name": "name", "type": "string" },
			{"name": "age",  "type": [ "float", "null" ] }
		]
	}
	for record in records:
		writer.write_record(record)

Result: python interpreted is aborted and "Segmentation fault" is raised.


Test Case 2 on Python 3.4.5:
Union data type: {"name": "age", "type": "float" }

records = [{"name": "Dark Larry", "age": 1108311.1},]
type(records[0]['age']) #float class 
import quickavro

with quickavro.FileWriter("example.avro") as writer:
	writer.schema = {
		"type": "record",
		"name": "Person",
		"fields": [
			{"name": "name", "type": "string" },
			{"name": "age",  "type":  "float" }
		]
	}
	for record in records:
		writer.write_record(record)

Result: Avro file is generated.

same behavior using Double instead float avro type

Definitely let me know if this doesn't fix your issue or you should find some more. And thanks for filling out the issue!