Created
April 13, 2020 19:57
-
-
Save emtwo/bc8e3303136822aa258099f0ecf63b17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Script to generate main summary test schema.""" | |
import json | |
PROBES_FILE = "histograms_probes.json" | |
probe_lists = {"parent": [], "content": []} | |
with open(PROBES_FILE) as probes_file: | |
probes = json.load(probes_file) | |
for probe, processes in probes.items(): | |
for process in processes: | |
probe_lists[process].append( | |
{"type": "STRING", "name": probe, "mode": "NULLABLE"} | |
) | |
json_schema_template = [ | |
{"type": "TIMESTAMP", "name": "submission_timestamp", "mode": "REQUIRED"}, | |
{"type": "INTEGER", "name": "sample_id", "mode": "REQUIRED"}, | |
{"type": "STRING", "name": "document_id", "mode": "NULLABLE"}, | |
{"type": "STRING", "name": "client_id", "mode": "NULLABLE"}, | |
{"type": "STRING", "name": "normalized_channel", "mode": "NULLABLE"}, | |
{"type": "STRING", "name": "normalized_os", "mode": "NULLABLE"}, | |
{ | |
"fields": [ | |
{"type": "STRING", "name": "version", "mode": "NULLABLE"}, | |
{"type": "STRING", "name": "build_id", "mode": "NULLABLE"}, | |
], | |
"type": "RECORD", | |
"name": "application", | |
"mode": "NULLABLE", | |
}, | |
{ | |
"fields": [ | |
{ | |
"fields": [ | |
{ | |
"fields": [ | |
{ | |
"fields": probe_lists["content"], | |
"type": "RECORD", | |
"name": "histograms", | |
"mode": "NULLABLE", | |
} | |
], | |
"type": "RECORD", | |
"name": "content", | |
"mode": "NULLABLE", | |
} | |
], | |
"type": "RECORD", | |
"name": "processes", | |
"mode": "NULLABLE", | |
}, | |
{ | |
"fields": probe_lists["parent"], | |
"type": "RECORD", | |
"name": "histograms", | |
"mode": "NULLABLE", | |
}, | |
], | |
"type": "RECORD", | |
"name": "payload", | |
"mode": "NULLABLE", | |
}, | |
] | |
print(json.dumps(json_schema_template, indent=4, sort_keys=True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment