Skip to content

Commit dfd1534

Browse files
ffissoreedenhill
authored andcommitted
Extended advanced test schema with a logical type, in order to test how avro schema is serialized to json
1 parent 69b04b5 commit dfd1534

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/avro/adv_schema.avsc

+11
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@
5656
"type" : "map",
5757
"values" : "basicPerson"
5858
}
59+
},
60+
{
61+
"name": "timestamp",
62+
"type": [
63+
"null",
64+
{
65+
"type": "long",
66+
"logicalType": "timestamp-millis"
67+
}
68+
],
69+
"default": null
5970
}
6071
]
6172
}

tests/avro/data_gen.py

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os
2323
import os.path
2424
import random
25+
from datetime import datetime, timezone
2526

2627
from avro import schema
2728
from avro.datafile import DataFileWriter
@@ -65,6 +66,7 @@ def create_adv_item(i):
6566
basic = create_basic_item(i)
6667
basic['family'] = dict(map(lambda bi: (bi['name'], bi), family))
6768
basic['friends'] = dict(map(lambda bi: (bi['name'], bi), friends))
69+
basic['timestamp'] = datetime(1970, 1, 1, 0, 0, tzinfo=timezone.utc)
6870
return basic
6971

7072

0 commit comments

Comments
 (0)