Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

shell

unix

avro

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?

like image 580
jeevan kishore Avatar asked Apr 26 '18 08:04

jeevan kishore


People also ask

How to decode Avro data using from_Avro () function?

To decode Avro data, we should use from_avro () function and this function takes Avro schema string as a parameter. For our example, I am going to load this schema from a person.avsc file. For reference, below is Avro’s schema we going to use. The Schema defines the field names and data types.

How to serialize the data using Avro in Java?

To serialize the data using Avro, follow the steps as given below − Write an Avro schema. Compile the schema using Avro utility. You get the Java code corresponding to that schema. Populate the schema with the data. Serialize it using Avro library.

How do I generate code from Avro schema?

Generating C# code from Avro schemas Chr.Avrois capable of generating rudimentary C# class and enum definitions to match Avro’s record and enum schemas. If you have a complex Avro schema, but no matching .NET type, code generation can save a lot of time. Getting started If you haven’t already, install the Chr.AvroCLI:

What is the Avro format?

The avro format has a generous data structure in which we can able to generate records having an array, enumerated type, and a sub-record. The avro format will have rich applicants for reserving the data in data lake landing blocks in which each block can object, size, a compressed object.


1 Answers

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
like image 159
hlagos Avatar answered Oct 03 '22 05:10

hlagos