@@ -22,17 +22,19 @@ object Schemas {
22
22
23
23
case class PrimitiveDef (
24
24
typeName : PrimitiveTypeName ,
25
- annotation : LogicalTypeAnnotation ,
25
+ annotation : Option [ LogicalTypeAnnotation ] = None ,
26
26
isOptional : Boolean = false ,
27
27
length : Int = 0
28
28
) extends Def [PrimitiveDef ] {
29
29
30
- def named (name : String ): Type =
31
- Types
32
- .primitive(typeName, repetition(isOptional))
33
- .as(annotation)
30
+ def named (name : String ): Type = {
31
+ val builder = Types .primitive(typeName, repetition(isOptional))
32
+
33
+ annotation
34
+ .fold(builder)(builder.as)
34
35
.length(length)
35
36
.named(name)
37
+ }
36
38
37
39
def length (len : Int ): PrimitiveDef =
38
40
this .copy(length = len)
@@ -104,13 +106,36 @@ object Schemas {
104
106
import PrimitiveTypeName ._
105
107
import LogicalTypeAnnotation ._
106
108
107
- val string : PrimitiveDef = PrimitiveDef (BINARY , stringType())
108
- val boolean : PrimitiveDef = PrimitiveDef (INT32 , intType(8 , false ))
109
- val byte : PrimitiveDef = PrimitiveDef (INT32 , intType(8 , false ))
110
- val short : PrimitiveDef = PrimitiveDef (INT32 , intType(16 , true ))
111
- val int : PrimitiveDef = PrimitiveDef (INT32 , intType(32 , true ))
112
- val long : PrimitiveDef = PrimitiveDef (INT64 , intType(64 , true ))
113
- val uuid : PrimitiveDef = PrimitiveDef (FIXED_LEN_BYTE_ARRAY , uuidType()).length(16 )
109
+ def enum0 : PrimitiveDef = PrimitiveDef (BINARY , Some (enumType()))
110
+ val string : PrimitiveDef = PrimitiveDef (BINARY , Some (stringType()))
111
+ val boolean : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(8 , false )))
112
+ val byte : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(8 , false )))
113
+ val short : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(16 , true )))
114
+ val int : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(32 , true )))
115
+ val long : PrimitiveDef = PrimitiveDef (INT64 , Some (intType(64 , true )))
116
+ val float : PrimitiveDef = PrimitiveDef (FLOAT )
117
+ val double : PrimitiveDef = PrimitiveDef (DOUBLE )
118
+ val binary : PrimitiveDef = PrimitiveDef (BINARY )
119
+ val char : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(8 , false )))
120
+ val uuid : PrimitiveDef = PrimitiveDef (FIXED_LEN_BYTE_ARRAY , Some (uuidType())).length(16 )
121
+ val bigDecimal : PrimitiveDef = PrimitiveDef (INT64 , Some (decimalType(11 , 2 )))
122
+ val bigInteger : PrimitiveDef = PrimitiveDef (BINARY )
123
+ val dayOfWeek : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(8 , false )))
124
+ val monthType : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(8 , false )))
125
+ val monthDay : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(8 , false )))
126
+ val period : PrimitiveDef = PrimitiveDef (FIXED_LEN_BYTE_ARRAY ).length(12 )
127
+ val year : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(16 , false )))
128
+ val yearMonth : PrimitiveDef = PrimitiveDef (INT32 , Some (intType(32 , false )))
129
+ val zoneId : PrimitiveDef = PrimitiveDef (BINARY , Some (stringType()))
130
+ val zoneOffset : PrimitiveDef = PrimitiveDef (BINARY , Some (stringType()))
131
+ val duration : PrimitiveDef = PrimitiveDef (INT64 , Some (intType(64 , false )))
132
+ val instant : PrimitiveDef = PrimitiveDef (INT64 , Some (intType(64 , false )))
133
+ val localDate : PrimitiveDef = PrimitiveDef (INT32 , Some (dateType()))
134
+ val localTime : PrimitiveDef = PrimitiveDef (INT32 , Some (timeType(true , TimeUnit .MILLIS )))
135
+ val localDateTime : PrimitiveDef = PrimitiveDef (INT64 , Some (timestampType(true , TimeUnit .MILLIS )))
136
+ val offsetTime : PrimitiveDef = PrimitiveDef (INT32 , Some (timeType(false , TimeUnit .MILLIS )))
137
+ val offsetDateTime : PrimitiveDef = PrimitiveDef (INT64 , Some (timestampType(false , TimeUnit .MILLIS )))
138
+ val zonedDateTime : PrimitiveDef = PrimitiveDef (INT64 , Some (timestampType(false , TimeUnit .MILLIS )))
114
139
115
140
def record (fields : Chunk [Type ]): RecordDef = RecordDef (fields)
116
141
def list (element : Type ): ListDef = ListDef (element)
0 commit comments