SiteWise avro file schema

0

I understand from this document all about how files in the cold tier are stored as S3 objects. What I think is missing is the actual avro schema file needed to load these files into something like a local Jupyter notebook. This schema file should look like this:

{
   "type" : "record",
   "namespace" : "Tutorialspoint",
   "name" : "Employee",
   "fields" : [
      { "name" : "Name" , "type" : "string" },
      { "name" : "Age" , "type" : "int" }
   ]
}

Is this schema the same for every SiteWise installation or does it depend on my model? Is there a way to export it from my model or asset? I just want to be able to peek through these files with my own software.

profile picture
wz2b
gefragt vor 2 Jahren284 Aufrufe
1 Antwort
1

SiteWise exports the Avro Schema into the header of the exported .avro file, so no need to load a separate Avro schema when reading the file. Here a sample python script to read a SiteWise avro export and dumps the schema:

>>> from avro.io import DatumReader
>>> from avro.datafile import DataFileReader
>>> avro_reader = DataFileReader(open("/tmp/raw_a50553ae-184e-4cea-ba5a-847e6d76e4ac_c82738f4-d145-4b12-8b6a-
>>> avro_reader.meta
{'avro.schema': b'{"type":"record","name":"RawDatum","namespace":"amazon.aws.iot.sitewise.raw","fields":[{"name":"seriesId","type":"string"},{"name":"timeInSeconds","type":"long"},{"name":"offsetInNanos","type":"long"},{"name":"quality","type":"string"},{"name":"doubleValue","type":["null","double"],"default":null},{"name":"stringValue","type":["null","string"],"default":null},{"name":"integerValue","type":["null","int"],"default":null},{"name":"booleanValue","type":["null","boolean"],"default":null},{"name":"jsonValue","type":["null","string"],"default":null},{"name":"recordVersion","type":["null","long"],"default":null}]}', 'avro.codec': b'snappy'}
profile pictureAWS
EXPERTE
Jan_B
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen