Package org.apache.avro
Class LogicalType
java.lang.Object
org.apache.avro.LogicalType
- Direct Known Subclasses:
LogicalTypes.BigDecimal
,LogicalTypes.Date
,LogicalTypes.Decimal
,LogicalTypes.Duration
,LogicalTypes.LocalTimestampMicros
,LogicalTypes.LocalTimestampMillis
,LogicalTypes.LocalTimestampNanos
,LogicalTypes.TimeMicros
,LogicalTypes.TimeMillis
,LogicalTypes.TimestampMicros
,LogicalTypes.TimestampMillis
,LogicalTypes.TimestampNanos
,LogicalTypes.Uuid
Logical types provides an opt-in way to extend Avro's types. Logical types
specify a way of representing a high-level type as a base Avro type. For
example, a date is specified as the number of days after the unix epoch (or
before using a negative value). This enables extensions to Avro's type system
without breaking binary compatibility. Older versions see the base type and
ignore the logical type.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
LOGICAL_TYPE_PROP
- See Also:
-
-
Constructor Details
-
LogicalType
-
-
Method Details
-
getName
Get the name of this logical type.This name is set as the Schema property "logicalType".
- Returns:
- the String name of the logical type
-
addToSchema
Add this logical type to the given Schema.The "logicalType" property will be set to this type's name, and other type-specific properties may be added. The Schema is first validated to ensure it is compatible.
- Parameters:
schema
- a Schema- Returns:
- the modified Schema
- Throws:
IllegalArgumentException
- if the type and schema are incompatible
-
validate
Validate this logical type for the given Schema.This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.
- Parameters:
schema
- a Schema- Throws:
IllegalArgumentException
- if the type and schema are incompatible
-