how to create a ".avsc" file from an input avro file?
Asked Answered
C

1

7

how to create a ".avsc" file from avro header ?

Does the first line of content is a avsc file for that avro? Or does the avsc content should starts from : {"type":"record" upto "}avro?

I tried the above mentioned 2 steps but not able to generate expected avsc file?

Crossindex answered 26/4, 2018 at 8:35 Comment(0)
S
9

There are different ways to do this. You can to use using avro-tools like this

avro-tools -getschema youravrofile

Or programatically like this

DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
DataFileReader<GenericRecord> dataFileReader = new DataFileReader<>(new File("yourfile.avro"), datumReader);
Schema schema = dataFileReader.getSchema();
System.out.println(schema); // this will print the schema for you
Santinasantini answered 26/4, 2018 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.