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[T] REPEATED x Array REPEATED13 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 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}.
  15. Map key type in avro is fixed to string. Scala Map key type must be either String or CharSequence.