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 INT643
Char INT3 INT643 Char Integer3 INT323 Int3 INT643
Byte INT3 INT643 Byte Integer3 INT329 Int3 INT643
Short INT3 INT643 Short Integer3 INT329 Int3 INT643
Int INT INT643 Int Integer3 INT329 Int INT643
Long LONG INT64 Long Integer INT649 Long INT64
Float FLOAT FLOAT643 Float Double3 FLOAT Float FLOAT
Double DOUBLE FLOAT64 Double Double DOUBLE Double FLOAT3
CharSequence STRING x x x x x x
String STRING STRING String String BINARY String BYTES3
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 STRING3 String String3 BINARY/ENUM9 Enum BYTES3
BigInt x x BigInt x x x x
BigDecimal BYTES4 NUMERIC6 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 optional10 Size <= 1
Iterable[T]2 ARRAY REPEATED x Array REPEATED13 repeated Size >= 0
Nested RECORD STRUCT Flat8 Entity Group Message Flat8
Map[CharSequence, T] MAP[STRING, T] x x x x x
Map[String, T] MAP[STRING, T] x x x x x x
java.time.Instant LONG11 TIMESTAMP x Timestamp LOGICAL[TIMESTAMP]9 x x
java.time.LocalDateTime LONG11 DATETIME x x LOGICAL[TIMESTAMP]9 x x
java.time.OffsetTime x x x x LOGICAL[TIME]9 x x
java.time.LocalTime LONG11 TIME x x LOGICAL[TIME]9 x x
java.time.LocalDate INT11 DATE x x LOGICAL[DATE]9 x x
org.joda.time.LocalDate INT11 x x x x x x
org.joda.time.DateTime INT11 x x x x x x
org.joda.time.LocalTime INT11 x x x x x x
java.util.UUID STRING4 x ByteString (16 bytes) x FIXED[16] x x
(Long, Long, Long)12 FIXED[12] x x x x x x
  1. Those wrapped inUnsafeEnum are encoded as strings, see enums.md for more
  2. Any subtype of Iterable[T]
  3. Unsafe conversions, import magnolify.$MODULE.unsafe._
  4. Avro logical types (doc)
  5. UNION of [NULL, T] and defaults to NULL (doc)
  6. Fixed precision of 38 and scale of 9 (doc)
  7. All Scala types are encoded as big endian ByteString for Bigtable
  8. Nested fields are encoded flat with field names joined with ., e.g. level1.level2.level3
  9. 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._, or magnolify.avro.logical.nanos._ accordingly.
  10. See protobuf.md for more
  11. Logical types available at micro- or milli-second precision; import magnolify.avro.logical.micros._ or magnolify.avro.logical.millis._ accordingly. BigQuery-compatible conversions are available in magnolify.avro.logical.bigquery._.
  12. Special tuple used to represent Duration in the Avro spec. This has not been made implicit in Magnolify; import AvroType.afDuration implicitly to enable
  13. If magnolify.parquet.ParquetArray.AvroCompat._ is imported, array fields use the nested, Avro-compatible schema format: required group $FIELDNAME (LIST) { repeated $FIELDTYPE array ($FIELDSCHEMA); }.
  14. 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}.