Skip to content

Commit 0a7c0fe

Browse files
osopardo1osopardo1
osopardo1
authored and
osopardo1
committed
Add Instant as type
1 parent 3edd55b commit 0a7c0fe

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/src/main/scala/io/qbeast/core/transform/LinearTransformer.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package io.qbeast.core.transform
66
import io.qbeast.core.model.{OrderedDataType, QDataType}
77

88
import java.sql.{Date, Timestamp}
9+
import java.time.Instant
910

1011
object LinearTransformer extends TransformerType {
1112
override def transformerSimpleName: String = "linear"
@@ -26,8 +27,9 @@ case class LinearTransformer(columnName: String, dataType: QDataType) extends Tr
2627
// Very special case in which we load the transformation information from JSON options
2728
case d: java.lang.Long if dataType.name == "IntegerDataType" => d.intValue()
2829
case d: java.math.BigDecimal => d.doubleValue()
29-
case d: Timestamp => d.getTime()
30-
case d: Date => d.getTime()
30+
case d: Timestamp => d.getTime
31+
case d: Date => d.getTime
32+
case d: Instant => Timestamp.from(d).getTime
3133
case other => other
3234
}
3335
}

core/src/main/scala/io/qbeast/core/transform/Transformation.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
package io.qbeast.core.transform
55

66
import com.fasterxml.jackson.annotation.JsonTypeInfo
7-
import java.sql.{Timestamp, Date}
7+
8+
import java.sql.{Date, Timestamp}
9+
import java.time.Instant
810

911
/**
1012
* Double value transformation.
@@ -56,6 +58,7 @@ case class IdentityToZeroTransformation(identityValue: Any) extends Transformati
5658
case v: Number if v == identityValue => 0.0
5759
case v: Timestamp if v == identityValue => 0.0
5860
case v: Date if v == identityValue => 0.0
61+
case v: Instant if v == identityValue => 0.0
5962

6063
}
6164

0 commit comments

Comments
 (0)