Skip to content

Commit 30ee28b

Browse files
committed
#374 Remove minimum values for offset types.
This is because for inclusive intervals minimums are not needed.
1 parent 745315b commit 30ee28b

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

pramen/api/src/main/scala/za/co/absa/pramen/api/offset/OffsetValue.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ sealed trait OffsetValue extends Comparable[OffsetValue] {
3131
}
3232

3333
object OffsetValue {
34-
val MINIMUM_TIMESTAMP_EPOCH_MILLI: Long = -62135596800000L
35-
3634
case class DateTimeValue(t: Instant) extends OffsetValue {
3735
override val dataType: OffsetType = OffsetType.DateTimeType
3836

@@ -78,15 +76,6 @@ object OffsetValue {
7876
}
7977
}
8078

81-
def getMinimumForType(dataType: String): OffsetValue = {
82-
dataType match {
83-
case DATETIME_TYPE_STR => DateTimeValue(Instant.ofEpochMilli(MINIMUM_TIMESTAMP_EPOCH_MILLI)) // LocalDateTime.of(1, 1, 1, 0, 0, 0).toInstant(ZoneOffset.UTC).toEpochMilli
84-
case INTEGRAL_TYPE_STR => IntegralValue(Long.MinValue)
85-
case STRING_TYPE_STR => StringValue("")
86-
case _ => throw new IllegalArgumentException(s"Unknown offset data type: $dataType")
87-
}
88-
}
89-
9079
def fromString(dataType: String, value: String): Option[OffsetValue] = {
9180
if (value.isEmpty)
9281
None

pramen/api/src/test/scala/za/co/absa/pramen/api/offset/OffsetValueSuite.scala

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package za.co.absa.pramen.api.offset
1919
import org.apache.spark.sql.functions._
2020
import org.apache.spark.sql.types.{LongType, StringType}
2121
import org.scalatest.wordspec.AnyWordSpec
22-
import za.co.absa.pramen.api.offset.OffsetValue.MINIMUM_TIMESTAMP_EPOCH_MILLI
2322

2423
import java.time.Instant
2524

@@ -50,32 +49,6 @@ class OffsetValueSuite extends AnyWordSpec {
5049
}
5150
}
5251

53-
"getMinimumForType" should {
54-
"be able to get minimum value for datetime type" in {
55-
val offsetValue = OffsetValue.getMinimumForType("datetime")
56-
assert(offsetValue.dataType == OffsetType.DateTimeType)
57-
assert(offsetValue.valueString == MINIMUM_TIMESTAMP_EPOCH_MILLI.toString)
58-
}
59-
60-
"be able to get minimum value for integral type" in {
61-
val offsetValue = OffsetValue.getMinimumForType("integral")
62-
assert(offsetValue.dataType == OffsetType.IntegralType)
63-
assert(offsetValue.valueString == Long.MinValue.toString)
64-
}
65-
66-
"be able to get minimum value for string type" in {
67-
val offsetValue = OffsetValue.getMinimumForType("string")
68-
assert(offsetValue.dataType == OffsetType.StringType)
69-
assert(offsetValue.valueString == "")
70-
}
71-
72-
"throw an exception when trying to get minimum value for an unknown type" in {
73-
assertThrows[IllegalArgumentException] {
74-
OffsetValue.getMinimumForType("unknown")
75-
}
76-
}
77-
}
78-
7952
"fromString" should {
8053
"return None for an empty string" in {
8154
val offsetValue = OffsetValue.fromString("datetime", "")

0 commit comments

Comments
 (0)