Introduction to Avro Data Types
Avro data types are defined as avro is a serialization format that does not put up the issue even if its value can be changeable or not. It has been planned to modify the data type as it is a data integration service that has been utilized to proceed data over the platform; many typed systems are close to other typed systems, and instead of using a new data type, avro can utilize the avro serialization format, data types utilize the string and JSON objects. It has boolean, integer, floating-point, string primitives, null type, array, records, enumeration sets, byte sequence, fixed-width byte sequence, and tagged union.
List of Avro Data Types
Given below is the list of Avro Data Types:
1. Null Type
This type has been mentioned as “null” as a string in quotes; it has one realizable value but without quotes. The Portable Format Analytics (PFA) does not convert the type; it does not return any value.
The union of some types means string and null constitute as:
The above specifies that the string value will be missing as it differs from “string.”
This data type can be represented as “boolean”; it has true and false values but without quotes.
This type is not a subclass of integer; hence if we want to change a Boolean variable y into zero or one, then the expression will be as:
3. Integer Type
There are two integers types one is “int” for 32-bit signed integers, and the second is “long” for “64-bit” signed integers, in which the “int” format is the default for functions, and the exact integer will be in JSON and PFA expressions that translated as “int.”
4. Floating-Point Types
There are two floating points, one is “float” for 32-bit, and the second is “double” for 64-bit as “double” is the default for various functions, and the exact floating-point number will get in JSON format, and the appearance of PFA has been translated as, “double.”
5. String Type
This data type has been written as “string” it can take any reasonable Unicode sequence; these are not arrays as they can be changed.
It does not have any character type because characters can be constituted by strings having a length of 1. For example, in JSON format, the string value has been constituted as “hii.”
The PFA expressions have been constituted with string as:
The “init” section can accept the value as JSON.
6. Byte Types
This type can be represented as “bytes” it can allow any byte sequence; it does not have any sub-type, so we can call it the generality of string. It does not take an array, and it cannot be changeable.
In JSON, the value of “string” is like: “hi.”
In PFA expression, it has been allowed using either base-64 or as an envelope string, such as:
It is an analogous assembly of items in the ordered form; if we have y type, then that can be accomplished as:
An example of an array of strings written as:
If the array contains a mixed type of items, they have to be declared as a union; an array of a nullable and floating-point number is:
If we try to extract from the above array, then that item has been distributed to control “null” and “double.”
If the item may have any type, then we can able to establish a two-dimensional array in an array of arrays, such as:
In JSON format, an array object can be written in a square bracket as:
That has been written in PFA format as:
Maps are analogous; disordered key-value pairs with keys are strings if the array has an index(key) as a string, preferably the integer.
If we have a type y, then we can able to map from string to ‘y’, such as:
Examples of a map from a string to a floating-point number such:
It has the same rules as array have, as they are not changeable:
In JSON, a map object can be written as:
These are similar to maps, as it is a group of fixed-set fields, for example:
Record in JSON has been represented as:
For example, the above record can be represented as:
A particular record type can be defined once per PFA document in which the record is fully-qualified.
Record type example: binary tree with string as leaves:
Recursive record of providing the array or map as subfields:
Records have PFA values.
10. Enumeration Sets
Enumeration sets are described as “enums,” which have a limited set of strings, and the string has to be in avro names, such as given below:
Example of having six symbols:
The ‘name’ field is mandatory, ‘namespace’ is optional, and a particular enum type can only be defined per the PFA document. In JSON, the enum value can be represented by the symbol name.
PFA can utilize the enum sets for describing the fixed set of variables; for example above six symbols have been sorted as:
11. Fixed-width Byte Sequences
Avro can support the name as raw byte series having fixed-length, in which the 6-byte mac address has been described as:
As we have three named types, the ‘name’ field is mandatory and ‘namespace’ is optional; firstly, these are not deliberated for compact fill up in the serialization of the avro and are not explicitly helpful in PFA.
12. Tagged Unions
Avro and PFA have tagged unions, so the particular type of values is available; the union of M, N, and O has been represented as a list:
For example, has variable “null,” “string,” or a map of “int” as:
At least two types are required, types are not repeated, and they are not nested directly.
In this article, we conclude that the avro can define data type which can use the string and JSON objects as it can have the above set of a data type with different forms and expressions, so this article will help understand the concept of avro data type.
This is a guide to Avro Data Types. Here we discuss the introduction and list of avro data types for better understanding. You may also have a look at the following articles to learn more –