Skip to content

Commit

Permalink
Merge branch 'vinted-feat/time_millis'
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpeeters committed Aug 16, 2022
2 parents e832d1d + c5f5d57 commit c4ed652
Show file tree
Hide file tree
Showing 26 changed files with 126 additions and 65 deletions.
53 changes: 9 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ _NOTE: Currently logical types are only supported for `Standard` and `SpecificRe
* `decimal`: Annotates Avro `bytes` and `fixed` schemas to generate `BigDecimal`. Examples: [avdl](https://github.com/julianpeeters/sbt-avrohugger/blob/master/src/sbt-test/avrohugger/GenericSerializationTests/src/main/avro/logical.avdl#L6), [avsc](https://github.com/julianpeeters/sbt-avrohugger/blob/master/src/sbt-test/avrohugger/GenericSerializationTests/src/main/avro/logical.avsc#L6-L14).
* `timestamp-millis`: Annotates Avro `long` schemas to genarate `java.time.Instant` or `java.sql.Timestamp` (See [Customizable Type Mapping](https://github.com/julianpeeters/avrohugger#customizable-type-mapping)). Examples: [avdl](https://github.com/julianpeeters/sbt-avrohugger/blob/master/src/sbt-test/avrohugger/GenericSerializationTests/src/main/avro/logical.avdl#L8), [avsc](https://github.com/julianpeeters/sbt-avrohugger/blob/master/src/sbt-test/avrohugger/GenericSerializationTests/src/main/avro/logical.avsc#L15-L21).
* `uuid`: Annotates Avro `string` schemas (but not idls as of avro 1.8.2) to generate `java.util.UUID` (See [Customizable Type Mapping](https://github.com/julianpeeters/avrohugger#customizable-type-mapping)). Example: [avsc](https://github.com/julianpeeters/sbt-avrohugger/blob/master/src/sbt-test/avrohugger/GenericSerializationTests/src/main/avro/logical.avsc#L29-L35).
* `time-millis`: Annotates Avro `int` schemas to genarate `java.time.LocalTime` or `java.sql.Time`

##### Protocol Support:

Expand Down Expand Up @@ -299,50 +300,14 @@ Depends on [Avro](https://github.com/apache/avro) and [Treehugger](https://githu


Contributors:
- [Marius Soutier](https://github.com/mariussoutier)
- [Paul Pearcy](https://github.com/ppearcy)
- [Stefano Galarraga](https://github.com/galarragas)
- [Brian London](https://github.com/BrianLondon)
- [Matt Allen](https://github.com/Matt343)
- [Lars Albertsson](https://github.com/lallea)
- [alancnet](https://github.com/alancnet)
- [C-zito](https://github.com/C-Zito)
- [Eugene Platonov](https://github.com/jozic)
- [Matt Coffin](https://github.com/mcoffin)
- [Tim Chan](https://github.com/timchan-lumoslabs)
- [Jerome Wacongne](https://github.com/ch4mpy)
- [Ryan Koval](http://github.ryankoval.com)
- [Saket](https://github.com/skate056)
- [Jon Morra](https://github.com/jon-morra-zefr)
- [Simonas Gelazevicius](https://github.com/simsasg)
- [Daniel Davis](https://github.com/wabu)
- [Raúl Raja Martínez](https://github.com/raulraja)
- [Paul Snively](https://github.com/PaulAtBanno)
- [Zach Cox](https://github.com/zcox)
- [Kaur Matas](https://github.com/kmatasflp)
- [Marco Stefani](https://github.com/inafets)
- [Diego E. Alonso Blas](https://github.com/diesalbla)
- [Chris Albright](https://github.com/chrisalbright)
- [Andrew Gustafson](https://github.com/agustafson)
- [Fede Fernández](https://github.com/fedefernandez)
- [Francisco Díaz](https://github.com/franciscodr)
- [Kostya Golikov](https://github.com/lazyval)
- [Rob Landers](https://github.com/withinboredom)
- [Bobby Rauchenberg](https://github.com/bobbyrauchenberg)
- [Plínio Pantaleão](https://github.com/plinioj)
- [Simon Petty](https://github.com/simonpetty)
- [Leonard Ehrenfried](https://github.com/leonardehrenfried)
- [Sietse de Kaper](https://github.com/targeter)
- [Andreas Drobisch](https://github.com/adrobisch)
- [François Sarradin](https://github.com/fsarradin)
- [Martin Mauch](https://github.com/nightscape)
- [natefitzgerald](https://github.com/natefitzgerald)
- [niqdev](https://github.com/niqdev)
- [Konstantin](https://github.com/tyger)
- [Timo Schmid](https://github.com/timo-schmid)
- [Julien BENOIT](https://github.com/jbenoit2011)
- [Adam Drakeford](https://github.com/dr4ke616)
- [mcenkar](https://github.com/mcenkar)

| | | |
| :--- | :--- | :--- |
| [Marius Soutier](https://github.com/mariussoutier) </br> [Brian London](https://github.com/BrianLondon) </br> [alancnet](https://github.com/alancnet) </br> [Matt Coffin](https://github.com/mcoffin) </br> [Ryan Koval](http://github.ryankoval.com) </br> [Simonas Gelazevicius](https://github.com/simsasg) </br> [Paul Snively](https://github.com/PaulAtBanno) </br> [Marco Stefani](https://github.com/inafets) </br> [Andrew Gustafson](https://github.com/agustafson) </br> [Kostya Golikov](https://github.com/lazyval) </br> [Plínio Pantaleão](https://github.com/plinioj) </br> [Sietse de Kaper](https://github.com/targeter) </br> [Martin Mauch](https://github.com/nightscape) </br> [Konstantin](https://github.com/tyger) </br> [Adam Drakeford](https://github.com/dr4ke616) | [Paul Pearcy](https://github.com/ppearcy) </br> [Matt Allen](https://github.com/Matt343) </br> [C-zito](https://github.com/C-Zito) </br> [Tim Chan](https://github.com/timchan-lumoslabs) </br> [Saket](https://github.com/skate056) </br> [Daniel Davis](https://github.com/wabu) </br> [Zach Cox](https://github.com/zcox) </br> [Diego E. Alonso Blas](https://github.com/diesalbla) </br> [Fede Fernández](https://github.com/fedefernandez) </br> [Rob Landers](https://github.com/withinboredom) </br> [Simon Petty](https://github.com/simonpetty) </br> [Andreas Drobisch](https://github.com/adrobisch) </br> [natefitzgerald](https://github.com/natefitzgerald) </br> [Timo Schmid](https://github.com/timo-schmid) </br> [mcenkar](https://github.com/mcenkar) | [Stefano Galarraga](https://github.com/galarragas) </br> [Lars Albertsson](https://github.com/lallea) </br> [Eugene Platonov](https://github.com/jozic) </br> [Jerome Wacongne](https://github.com/ch4mpy) </br> [Jon Morra](https://github.com/jon-morra-zefr) </br> [Raúl Raja Martínez](https://github.com/raulraja) </br> [Kaur Matas](https://github.com/kmatasflp) </br> [Chris Albright](https://github.com/chrisalbright) </br> [Francisco Díaz](https://github.com/franciscodr) </br> [Bobby Rauchenberg](https://github.com/bobbyrauchenberg) </br> [Leonard Ehrenfried](https://github.com/leonardehrenfried) </br> [François Sarradin](https://github.com/fsarradin) </br> [niqdev](https://github.com/niqdev) </br> [Julien BENOIT](https://github.com/jbenoit2011) </br> [Algimantas Milašius](https://github.com/AlgMi) |





##### Criticism is appreciated.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ object JavaConverter {
case JavaSqlDate => tree.DOT("getTime").APPLY().DOT("/").APPLY(LIT(86400000))
case JavaTimeLocalDate => tree.DOT("toEpochDay").DOT("toInt")
}
case timeMillis: LogicalTypes.TimeMillis => typeMatcher.avroScalaTypes.timeMillis match {
case JavaSqlTime => tree.DOT("getTime").APPLY()
case JavaTimeLocalTime => tree.DOT("get").APPLY(REF("java.time.temporal.ChronoField").DOT("MILLI_OF_DAY"))
}
case _ => tree
}
case Schema.Type.STRING =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,24 @@ object ScalaConverter {
tree MATCH integerConversion
}
}

}
else if (logicalType.getName == "time-millis") {
typeMatcher.avroScalaTypes.timeMillis match {
case JavaSqlTime => {
val IntegerClass = RootClass.newClass("Integer")
val SqlTimeClass = RootClass.newClass("java.sql.Time")
val resultExpr = BLOCK(NEW(SqlTimeClass, REF("i").DOT("toLong")))
val integerConversion = CASE(ID("i") withType (IntegerClass)) ==> resultExpr
tree MATCH integerConversion
}
case JavaTimeLocalTime => {
val IntegerClass = RootClass.newClass("Integer")
val LocalTimeClass = RootClass.newClass("java.time.LocalTime")
val resultExpr = BLOCK(LocalTimeClass.DOT("ofNanoOfDay").APPLY(REF("i").INFIX("*", LIT(1000000L))))
val integerConversion = CASE(ID("i") withType (IntegerClass)) ==> resultExpr
tree MATCH integerConversion
}
}
}
else tree
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ object DefaultParamMatcher {
case Date =>
CustomDefaultParamMatcher.checkCustomDateType(
typeMatcher.avroScalaTypes.date)
case TimeMillis =>
CustomDefaultParamMatcher.checkCustomTimeMillisType(
typeMatcher.avroScalaTypes.timeMillis
)
}
case Type.LONG =>
LogicalType.foldLogicalTypes[Tree](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ object DefaultValueMatcher {
CustomDefaultValueMatcher.checkCustomDateType(
node.longValue(),
typeMatcher.avroScalaTypes.date)
case TimeMillis =>
CustomDefaultValueMatcher.checkCustomTimeMillisType(
node.longValue(),
typeMatcher.avroScalaTypes.timeMillis)
}
case Schema.Type.FLOAT => LIT(node.doubleValue().asInstanceOf[Float])
case Schema.Type.LONG =>
Expand Down
1 change: 1 addition & 0 deletions avrohugger-core/src/main/scala/matchers/TypeMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class TypeMatcher(
schema = schema,
default = CustomTypeMatcher.checkCustomNumberType(avroScalaTypes.int)) {
case Date => CustomTypeMatcher.checkCustomDateType(avroScalaTypes.date)
case TimeMillis => CustomTypeMatcher.checkCustomTimeMillisType(avroScalaTypes.timeMillis)
}
case Schema.Type.NULL => NullClass
case Schema.Type.STRING =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ object CustomDefaultParamMatcher {
}
}
}

def checkCustomTimeMillisType(timeMillisType: AvroScalaTimeMillisType) =
timeMillisType match {
case JavaSqlTime => NEW(REF("java.sql.Time"), LIT(0L))
case JavaTimeLocalTime => REF("java.time.LocalTime.now")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ object CustomDefaultValueMatcher {
case JavaTimeInstant => REF("java.time.Instant.ofEpochMilli") APPLY LIT(value)
}

def checkCustomTimeMillisType(value: Long, timeMillisType: AvroScalaTimeMillisType) =
timeMillisType match {
case JavaSqlTime => NEW("java.sql.Time", LIT(value))
case JavaTimeLocalTime => REF("java.time.LocalTime.ofNanoOfDay").APPLY(LIT(value).INFIX("*", LIT(1000000L)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ object CustomTypeMatcher {
case JavaTimeInstant => RootClass.newClass(nme.createNameType("java.time.Instant"))
}

def checkCustomTimeMillisType(timeType: AvroScalaTimeMillisType) = timeType match {
case JavaSqlTime => RootClass.newClass(nme.createNameType("java.sql.Time"))
case JavaTimeLocalTime => RootClass.newClass(nme.createNameType("java.time.LocalTime"))
}

def checkCustomDecimalType(decimalType: AvroScalaDecimalType, schema: Schema) =
LogicalType.foldLogicalTypes(
schema = schema,
Expand Down
1 change: 1 addition & 0 deletions avrohugger-core/src/main/scala/types/AvroScalaTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ case class AvroScalaTypes(
decimal: AvroScalaDecimalType = ScalaBigDecimal(None),
date: AvroScalaDateType = JavaTimeLocalDate,
timestampMillis: AvroScalaTimestampMillisType = JavaTimeInstant,
timeMillis: AvroScalaTimeMillisType = JavaTimeLocalTime,
uuid: AvroUuidType = JavaUuid
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ case object JavaTimeInstant extends AvroScalaTimestampMillisType
sealed trait AvroUuidType extends Product with Serializable
case object JavaUuid extends AvroUuidType

sealed trait AvroScalaTimeMillisType extends Product with Serializable
case object JavaSqlTime extends AvroScalaTimeMillisType
case object JavaTimeLocalTime extends AvroScalaTimeMillisType

sealed abstract class LogicalType(name: String)
case class Decimal(precision: Int, scale: Int) extends LogicalType("decimal")
case object Date extends LogicalType("date")
case object TimestampMillis extends LogicalType("timestamp-millis")
case object TimeMillis extends LogicalType("time-millis")
case object UUID extends LogicalType("uuid")

object LogicalType {
Expand All @@ -30,6 +35,7 @@ object LogicalType {
case d: org.apache.avro.LogicalTypes.Decimal => Some(Decimal(d.getPrecision, d.getScale))
case _: org.apache.avro.LogicalTypes.Date => Some(Date)
case _: org.apache.avro.LogicalTypes.TimestampMillis => Some(TimestampMillis)
case _: org.apache.avro.LogicalTypes.TimeMillis => Some(TimeMillis)
case _ if logicalType.getName == "uuid" => Some(UUID)
case _ => None
}
Expand Down
1 change: 1 addition & 0 deletions avrohugger-core/src/test/avro/logical.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ protocol LogicalIDL {
timestamp_ms ts = 1526573732000; //ms from the unix epoch
date dt = 600; //days from the unix epock, no time precission
decimal(20, 2) decBig = "\u000C\u006C";
time_ms tm = 43200000;
}

}
7 changes: 7 additions & 0 deletions avrohugger-core/src/test/avro/logical.avpr
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
"logicalType": "decimal",
"precision": 20,
"scale": 12
},
{
"name": "time",
"type": {
"type": "int",
"logicalType": "time-millis"
}
}
]
}
Expand Down
7 changes: 7 additions & 0 deletions avrohugger-core/src/test/avro/logical.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
"precision": 20,
"scale": 12
}
},
{
"name": "tm",
"type": {
"type": "int",
"logicalType": "time-millis"
}
}
]
}
7 changes: 7 additions & 0 deletions avrohugger-core/src/test/avro/logicalsql.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
"precision": 20,
"scale": 12
}
},
{
"name": "tm",
"type": {
"type": "int",
"logicalType": "time-millis"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package example.logical

import scala.annotation.switch

final case class LogicalSql(var data: BigDecimal, var ts: java.sql.Timestamp, var dt: java.sql.Date, var dataBig: BigDecimal) extends org.apache.avro.specific.SpecificRecordBase {
def this() = this(scala.math.BigDecimal(0), new java.sql.Timestamp(0L), new java.sql.Date(0L), scala.math.BigDecimal(0))
final case class LogicalSql(var data: BigDecimal, var ts: java.sql.Timestamp, var dt: java.sql.Date, var dataBig: BigDecimal, var tm: java.sql.Time) extends org.apache.avro.specific.SpecificRecordBase {
def this() = this(scala.math.BigDecimal(0), new java.sql.Timestamp(0L), new java.sql.Date(0L), scala.math.BigDecimal(0), new java.sql.Time(0L))
def get(field$: Int): AnyRef = {
(field$: @switch) match {
case 0 => {
Expand All @@ -29,6 +29,9 @@ final case class LogicalSql(var data: BigDecimal, var ts: java.sql.Timestamp, va
val bigDecimal = scaledValue.bigDecimal
LogicalSql.decimalConversion.toBytes(bigDecimal, schema, decimalType)
}.asInstanceOf[AnyRef]
case 4 => {
tm.getTime()
}.asInstanceOf[AnyRef]
case _ => new org.apache.avro.AvroRuntimeException("Bad index")
}
}
Expand Down Expand Up @@ -66,6 +69,13 @@ final case class LogicalSql(var data: BigDecimal, var ts: java.sql.Timestamp, va
}
}
}.asInstanceOf[BigDecimal]
case 4 => this.tm = {
value match {
case (i: Integer) => {
new java.sql.Time(i.toLong)
}
}
}.asInstanceOf[java.sql.Time]
case _ => new org.apache.avro.AvroRuntimeException("Bad index")
}
()
Expand All @@ -74,6 +84,6 @@ final case class LogicalSql(var data: BigDecimal, var ts: java.sql.Timestamp, va
}

object LogicalSql {
val SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"LogicalSql\",\"namespace\":\"example.logical\",\"fields\":[{\"name\":\"data\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":9,\"scale\":2}},{\"name\":\"ts\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"dt\",\"type\":{\"type\":\"int\",\"logicalType\":\"date\"}},{\"name\":\"dataBig\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":20,\"scale\":12}}]}")
val SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"LogicalSql\",\"namespace\":\"example.logical\",\"fields\":[{\"name\":\"data\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":9,\"scale\":2}},{\"name\":\"ts\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"dt\",\"type\":{\"type\":\"int\",\"logicalType\":\"date\"}},{\"name\":\"dataBig\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":20,\"scale\":12}},{\"name\":\"tm\",\"type\":{\"type\":\"int\",\"logicalType\":\"time-millis\"}}]}")
val decimalConversion = new org.apache.avro.Conversions.DecimalConversion
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package example.logical.proto

import scala.annotation.switch

final case class Logical(var dec: BigDecimal, var ts: java.time.Instant, var dt: java.time.LocalDate, var uuid: java.util.UUID, var decBig: BigDecimal) extends org.apache.avro.specific.SpecificRecordBase {
def this() = this(scala.math.BigDecimal(0), java.time.Instant.now, java.time.LocalDate.now, java.util.UUID.randomUUID, scala.math.BigDecimal(0))
final case class Logical(var dec: BigDecimal, var ts: java.time.Instant, var dt: java.time.LocalDate, var uuid: java.util.UUID, var decBig: BigDecimal, var time: java.time.LocalTime) extends org.apache.avro.specific.SpecificRecordBase {
def this() = this(scala.math.BigDecimal(0), java.time.Instant.now, java.time.LocalDate.now, java.util.UUID.randomUUID, scala.math.BigDecimal(0), java.time.LocalTime.now)
def get(field$: Int): AnyRef = {
(field$: @switch) match {
case 0 => {
Expand Down Expand Up @@ -32,6 +32,9 @@ final case class Logical(var dec: BigDecimal, var ts: java.time.Instant, var dt:
val bigDecimal = scaledValue.bigDecimal
Logical.decimalConversion.toBytes(bigDecimal, schema, decimalType)
}.asInstanceOf[AnyRef]
case 5 => {
time.get(java.time.temporal.ChronoField.MILLI_OF_DAY)
}.asInstanceOf[AnyRef]
case _ => new org.apache.avro.AvroRuntimeException("Bad index")
}
}
Expand Down Expand Up @@ -76,6 +79,13 @@ final case class Logical(var dec: BigDecimal, var ts: java.time.Instant, var dt:
}
}
}.asInstanceOf[BigDecimal]
case 5 => this.time = {
value match {
case (i: Integer) => {
java.time.LocalTime.ofNanoOfDay(i * 1000000L)
}
}
}.asInstanceOf[java.time.LocalTime]
case _ => new org.apache.avro.AvroRuntimeException("Bad index")
}
()
Expand All @@ -84,6 +94,6 @@ final case class Logical(var dec: BigDecimal, var ts: java.time.Instant, var dt:
}

object Logical {
val SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Logical\",\"namespace\":\"example.logical.proto\",\"fields\":[{\"name\":\"dec\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":9,\"scale\":2},\"logicalType\":\"decimal\",\"precision\":9,\"scale\":2},{\"name\":\"ts\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"dt\",\"type\":{\"type\":\"int\",\"logicalType\":\"date\"}},{\"name\":\"uuid\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"decBig\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":20,\"scale\":12},\"logicalType\":\"decimal\",\"precision\":20,\"scale\":12}]}")
val SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Logical\",\"namespace\":\"example.logical.proto\",\"fields\":[{\"name\":\"dec\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":9,\"scale\":2},\"logicalType\":\"decimal\",\"precision\":9,\"scale\":2},{\"name\":\"ts\",\"type\":{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}},{\"name\":\"dt\",\"type\":{\"type\":\"int\",\"logicalType\":\"date\"}},{\"name\":\"uuid\",\"type\":{\"type\":\"string\",\"logicalType\":\"uuid\"}},{\"name\":\"decBig\",\"type\":{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":20,\"scale\":12},\"logicalType\":\"decimal\",\"precision\":20,\"scale\":12},{\"name\":\"time\",\"type\":{\"type\":\"int\",\"logicalType\":\"time-millis\"}}]}")
val decimalConversion = new org.apache.avro.Conversions.DecimalConversion
}
Loading

0 comments on commit c4ed652

Please sign in to comment.