Class Schema
An Avro Schema is one of the following:
- A JSON string, matching a defined type like "int", "string", or another Schema's name.
- A JSON object, of the form {"type": "typeName", ...attributes...}
.
- A JSON array of type names like ["null", "string"]
, representing a union where values
adhering to the schema may be one of the listed types.
class Schema
;
It should be noted that certain types can contain schemas via their attributes, making a Schema a tree-like structure with each Schema having potential nested schemas.
Methods
Name | Description |
---|---|
addAlias
(name, namespace)
|
If this is a record, enum, or fixed, add an alias. |
createPrimitive
(type)
|
Creates a schema given a primitive type. |
getAliases
()
|
If this is a record, enum, or fixed, return its aliases, if any. |
getDoc
()
|
If this is a record, enum, or fixed, returns its docstring, if available. Otherwise, returns null. |
getElementSchema
()
|
If this is an array, returns its element type. |
getEnumDefault
()
|
If this is an enum, return its default value. |
getEnumOrdinal
(symbol)
|
If this is an enum, return a symbol's ordinal value. |
getEnumSymbols
()
|
If this is an enum, return its symbols. |
getField
(fieldName)
|
If this is a record, returns the Field with the given name [fieldName]. If there is no field by that name, a [null] is returned. |
getFields
()
|
If this is a record, returns the fields in it. The returned list is in the order of their positions. |
getFixedSize
()
|
If this is fixed, returns its size. |
getFullname
()
|
If this is a record, enum or fixed, returns its namespace-qualified name, otherwise returns the name of the primitive type. |
getIndexNamed
(name)
|
If this is a union, return the branch with the provided full name. |
getLogicalType
()
|
Return the logical type, which can be combined with a type for special interpretation, like a timestamp or a date. |
getName
()
|
If this is a record, enum, or fixed, return its name, otherwise return the name of the primitive type. |
getNamespace
()
|
If this is a record, enum or fixed, returns its namespace, if any. |
getType
()
|
Return the type of this schema. |
getTypes
()
|
If this is a union, returns its types. |
getValueSchema
()
|
If this is a map, returns its value type. |
hasEnumSymbol
(symbol)
|
If this is an enum, returns true if it contains given symbol. |
isError
()
|
Indicates whether the schema is a both a record an an error type in a protocol. |
setFields
(fields)
|
If this is a record, set its fields. The fields can be set only once in a schema. |
toString
()
|
Creates a textual representation of a Schema in JSON. |
See Also
https://avro.apache.org/docs/current/spec.html#schemas