Skip to content

Commit 17ab596

Browse files
committed
#658 Add support for case insensitive offset types.
1 parent e5b72cc commit 17ab596

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object OffsetType {
5757
override def getSparkCol(c: Column): Column = c
5858
}
5959

60-
def fromString(dataType: String): OffsetType = dataType match {
60+
def fromString(dataType: String): OffsetType = dataType.trim.toLowerCase match {
6161
case DATETIME_TYPE_STR => DateTimeType
6262
case INTEGRAL_TYPE_STR => IntegralType
6363
case INTEGRAL_TYPE_ALT_STR => IntegralType

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ class OffsetTypeSuite extends AnyWordSpec {
4747
assert(offsetValue.dataTypeString == "datetime")
4848
}
4949

50+
"be able to create a DateTimeType instance from a string with different case" in {
51+
val offsetValue = OffsetType.fromString("dateTime")
52+
assert(offsetValue.dataTypeString == "datetime")
53+
}
54+
55+
"be able to create a DateTimeType instance from a string with different case and spaces" in {
56+
val offsetValue = OffsetType.fromString(" DATETIME ")
57+
assert(offsetValue.dataTypeString == "datetime")
58+
}
59+
5060
"be able to create a IntegralType instance from a string" in {
5161
val offsetValue = OffsetType.fromString("integral")
5262
assert(offsetValue.dataTypeString == "integral")

0 commit comments

Comments
 (0)