Type Mapping
Scala | Avro | BigQuery | Bigtable7 | Datastore | Parquet | Protobuf | TensorFlow |
---|---|---|---|---|---|---|---|
Unit |
null |
x | x | Null |
x | x | x |
Boolean |
boolean |
BOOL |
Byte |
Boolean |
BOOLEAN |
Boolean |
INT64 3 |
Char |
int 3 |
INT64 3 |
Char |
Integer 3 |
INT32 3 |
Int 3 |
INT64 3 |
Byte |
int 3 |
INT64 3 |
Byte |
Integer 3 |
INT32 9 |
Int 3 |
INT64 3 |
Short |
int 3 |
INT64 3 |
Short |
Integer 3 |
INT32 9 |
Int 3 |
INT64 3 |
Int |
int |
INT64 3 |
Int |
Integer 3 |
INT32 9 |
Int |
INT64 3 |
Long |
long |
INT64 |
Long |
Integer |
INT64 9 |
Long |
INT64 |
Float |
float |
FLOAT64 3 |
Float |
Double 3 |
FLOAT |
Float |
FLOAT |
Double |
double |
FLOAT64 |
Double |
Double |
DOUBLE |
Double |
FLOAT 3 |
CharSequence |
string |
x | x | x | x | x | x |
String |
string |
STRING |
String |
String |
BINARY |
String |
BYTES 3 |
Array[Byte] |
bytes |
BYTES |
ByteString |
Blob |
BINARY |
ByteString |
BYTES |
ByteString |
x | x | ByteString |
Blob |
x | ByteString |
BYTES |
ByteBuffer |
bytes |
x | x | x | x | x | |
Enum1 | enum |
STRING 3 |
String |
String 3 |
BINARY /ENUM 9 |
Enum | BYTES 3 |
BigInt |
x | x | BigInt |
x | x | x | x |
BigDecimal |
bytes 4 |
NUMERIC 6 |
Int scale + unscaled BigInt |
x | LOGICAL[DECIMAL] 9,14 |
x | x |
Option[T] |
union[null, T] 5 |
NULLABLE |
Empty as None |
Absent as None |
OPTIONAL |
optional 10 |
Size <= 1 |
Iterable[T] 2 |
array[T] |
REPEATED |
x | Array |
REPEATED 13 |
repeated |
Size >= 0 |
Nested | record |
STRUCT |
Flat8 | Entity |
Group | Message |
Flat8 |
Map[K, V] |
map[V] 15 |
x | x | x | x | map<K, V> |
x |
java.time.Instant |
long 11 |
TIMESTAMP |
x | Timestamp |
LOGICAL[TIMESTAMP] 9 |
x | x |
java.time.LocalDateTime |
long 11 |
DATETIME |
x | x | LOGICAL[TIMESTAMP] 9 |
x | x |
java.time.OffsetTime |
x | x | x | x | LOGICAL[TIME] 9 |
x | x |
java.time.LocalTime |
long 11 |
TIME |
x | x | LOGICAL[TIME] 9 |
x | x |
java.time.LocalDate |
int 11 |
DATE |
x | x | LOGICAL[DATE] 9 |
x | x |
org.joda.time.LocalDate |
int 11 |
x | x | x | x | x | x |
org.joda.time.DateTime |
int 11 |
x | x | x | x | x | x |
org.joda.time.LocalTime |
int 11 |
x | x | x | x | x | x |
java.util.UUID |
string 4 |
x | ByteString (16 bytes) | x | FIXED[16] |
x | x |
(Long, Long, Long) 12 |
fixed[12] |
x | x | x | x | x | x |
- Those wrapped in
UnsafeEnum
are encoded as strings, see enums.md for more - Any subtype of
Iterable[T]
- Unsafe conversions,
import magnolify.$MODULE.unsafe._
- Avro logical types (doc)
UNION
of[NULL, T]
and defaults toNULL
(doc)- Fixed precision of 38 and scale of 9 (doc)
- All Scala types are encoded as big endian
ByteString
for Bigtable - Nested fields are encoded flat with field names joined with
.
, e.g.level1.level2.level3
- More information on Parquet logical type schemas can be found here. Time types are available at multiple precisions; import
magnolify.parquet.logical.micros._
,magnolify.avro.logical.millis._
, ormagnolify.avro.logical.nanos._
accordingly. - See protobuf.md for more
- Logical types available at micro- or milli-second precision; import
magnolify.avro.logical.micros._
ormagnolify.avro.logical.millis._
accordingly. BigQuery-compatible conversions are available inmagnolify.avro.logical.bigquery._
. - Special tuple used to represent Duration in the Avro spec. This has not been made implicit in Magnolify; import
AvroType.afDuration
implicitly to enable - If
magnolify.parquet.ParquetArray.AvroCompat._
is imported, array fields use the nested, Avro-compatible schema format:required group $FIELDNAME (LIST) { repeated $FIELDTYPE array ($FIELDSCHEMA); }
. - Parquet’s Decimal logical format supports multiple representations, and are not implicitly scoped by default. Import one of:
magnolify.parquet.ParquetField.{decimal32, decimal64, decimalFixed, decimalBinary}
. - Map key type in avro is fixed to string. Scala Map key type must be either
String
orCharSequence
.
0.7.4