Skip to content

Commit c1a5d65

Browse files
authored
Merge pull request #206 from osopardo1/145-hive-instant
Fixes #140
2 parents 3edd55b + e36cc46 commit c1a5d65

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ import com.fasterxml.jackson.databind.node.{DoubleNode, IntNode, NumericNode, Te
1111
import com.fasterxml.jackson.databind.ser.std.StdSerializer
1212
import com.fasterxml.jackson.databind.{DeserializationContext, SerializerProvider}
1313
import io.qbeast.core.model.{
14+
DateDataType,
1415
DecimalDataType,
1516
DoubleDataType,
1617
FloatDataType,
1718
IntegerDataType,
1819
LongDataType,
1920
OrderedDataType,
20-
TimestampDataType,
21-
DateDataType
21+
TimestampDataType
2222
}
2323

2424
import java.math.BigDecimal
25-
import java.sql.{Timestamp, Date}
25+
import java.sql.{Date, Timestamp}
26+
import java.time.Instant
2627
import scala.util.Random
2728
import scala.util.hashing.MurmurHash3
2829

@@ -62,6 +63,7 @@ case class LinearTransformation(
6263
case v: Float => (v - mn) * scale
6364
case v: Timestamp => (v.getTime - mn) * scale
6465
case v: Date => (v.getTime - mn) * scale
66+
case v: Instant => (v.toEpochMilli - mn) * scale
6567
}
6668
}
6769

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

+4-2
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 => d.toEpochMilli
3133
case other => other
3234
}
3335
}

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

+4-1
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)