@@ -114,32 +114,34 @@ and that's about it, for now.
114
114
115
115
## Avro Logical Types
116
116
117
- Following is an extract from [ Logical Types] ( http://avro.apache.org/docs/current/specification/_print/#logical-types ) paragraph in
118
- Avro schema specification:
117
+ The following is an excerpt from the [ Logical Types] ( https://avro.apache.org/docs/1.11.1/specification/#logical-types ) section of
118
+ the Avro schema specification:
119
+
119
120
> A logical type is an Avro primitive or complex type with extra attributes to represent a derived type. The attribute
120
- > ` logicalType ` is always be present for a logical type, and is a string with the name of one of the logical types
121
- > defined by Avro specification.
121
+ > ` logicalType ` must always be present for a logical type, and is a string with the name of one of the logical types
122
+ > listed later in this section. Other attributes may be defined for particular logical types.
123
+
124
+ Logical types are supported for a limited set of ` java.time ` classes and for 'java.util.UUID'. See the table below for more details.
122
125
123
- Generation of logical types for limited set of ` java.time ` classes is supported at the moment. See a table bellow.
126
+ ### Mapping to Logical Types
124
127
125
- ### Mapping to Logical Type
128
+ Mapping to Avro type and logical type involves these steps:
126
129
127
- Mapping to Avro type and logical type works in few steps:
128
- 1 . Serializer for particular Java type (or class) determines a Jackson type where the Java type will be serialized into.
129
- 2 . ` AvroSchemaGenerator ` determines corresponding Avro type for that Jackson type.
130
- 2 . If logical type generation is enabled, then ` logicalType ` is determined for the above combination of Java type and
131
- Avro type.
130
+ 1 . The serializer for a Java type identifies the Jackson type it will serialize into.
131
+ 2 . The ` AvroSchemaGenerator ` maps that Jackson type to the corresponding Avro type.
132
+ 3 . ` logicalType ` value is combination of Java type and Jackson type.
132
133
133
134
#### Java type to Avro Logical Type mapping
134
135
135
- | Java type | Serialization type | Generated Avro schema with Avro type and logical type
136
- | ----------------------------- | ------------------ | -----------------------------------------------------
137
- | ` java.time.OffsetDateTime ` | NumberType.LONG | ` {"type": "long", "logicalType": "timestamp-millis"} `
138
- | ` java.time.ZonedDateTime ` | NumberType.LONG | ` {"type": "long", "logicalType": "timestamp-millis"} `
139
- | ` java.time.Instant ` | NumberType.LONG | ` {"type": "long", "logicalType": "timestamp-millis"} `
140
- | ` java.time.LocalDate ` | NumberType.INT | ` {"type": "int", "logicalType": "date"} `
141
- | ` java.time.LocalTime ` | NumberType.INT | ` {"type": "int", "logicalType": "time-millis"} `
142
- | ` java.time.LocalDateTime ` | NumberType.LONG | ` {"type": "long", "logicalType": "local-timestamp-millis"} `
136
+ | Java type | Jackson type | Generated Avro schema with logical type |
137
+ | ----------------------------| -----------------| ---------------------------------------------------------------------------------------------------|
138
+ | ` java.time.OffsetDateTime ` | NumberType.LONG | ` {"type": "long", "logicalType": "timestamp-millis"} ` |
139
+ | ` java.time.ZonedDateTime ` | NumberType.LONG | ` {"type": "long", "logicalType": "timestamp-millis"} ` |
140
+ | ` java.time.Instant ` | NumberType.LONG | ` {"type": "long", "logicalType": "timestamp-millis"} ` |
141
+ | ` java.time.LocalDate ` | NumberType.INT | ` {"type": "int", "logicalType": "date"} ` |
142
+ | ` java.time.LocalTime ` | NumberType.INT | ` {"type": "int", "logicalType": "time-millis"} ` |
143
+ | ` java.time.LocalDateTime ` | NumberType.LONG | ` {"type": "long", "logicalType": "local-timestamp-millis"} ` |
144
+ | ` java.util.UUID ` (2.19+) | | ` {"type": "fixed", "name": "UUID", "namespace": "java.util", "size": 16, "logicalType" : "uuid"} ` |
143
145
144
146
_ Provided Avro logical type generation is enabled._
145
147
0 commit comments