@@ -366,17 +366,25 @@ class CosmosRowConverterSpec extends UnitSpec with BasicLoggingTrait {
366
366
" date and time in spark row" should " translate to ObjectNode" in {
367
367
val colName1 = " testCol1"
368
368
val colName2 = " testCol2"
369
+ val colName3 = " testCol3"
370
+ val colName4 = " testCol4"
369
371
val currentMillis = System .currentTimeMillis()
370
372
val colVal1 = new Date (currentMillis)
371
373
val colVal2 = new Timestamp (colVal1.getTime)
374
+ val colVal3 = currentMillis.toInt
372
375
373
376
val row = new GenericRowWithSchema (
374
- Array (colVal1, colVal2),
375
- StructType (Seq (StructField (colName1, DateType ), StructField (colName2, TimestampType ))))
377
+ Array (colVal1, colVal2, colVal3, colVal3),
378
+ StructType (Seq (StructField (colName1, DateType ),
379
+ StructField (colName2, TimestampType ),
380
+ StructField (colName3, DateType ),
381
+ StructField (colName4, TimestampType ))))
376
382
377
383
val objectNode = defaultRowConverter.fromRowToObjectNode(row)
378
384
objectNode.get(colName1).asLong() shouldEqual currentMillis
379
385
objectNode.get(colName2).asLong() shouldEqual currentMillis
386
+ objectNode.get(colName3).asInt() shouldEqual colVal3
387
+ objectNode.get(colName4).asInt() shouldEqual colVal3
380
388
}
381
389
382
390
" numeric types in spark row" should " translate to ObjectNode" in {
@@ -969,6 +977,7 @@ class CosmosRowConverterSpec extends UnitSpec with BasicLoggingTrait {
969
977
val colName2 = " testCol2"
970
978
val colName3 = " testCol3"
971
979
val colName4 = " testCol4"
980
+ val colName5 = " testCol5"
972
981
val colVal1 = System .currentTimeMillis()
973
982
val colVal1AsTime = new Date (colVal1)
974
983
val colVal2 = System .currentTimeMillis()
@@ -979,17 +988,20 @@ class CosmosRowConverterSpec extends UnitSpec with BasicLoggingTrait {
979
988
val ff = DateTimeFormatter
980
989
.ofPattern(" yyyy-MM-dd'T'HH:mm:ss'Z'" ).withZone(ZoneOffset .UTC )
981
990
val colVal4AsTime = Date .valueOf(LocalDateTime .parse(colVal4, ff).toLocalDate)
991
+ val colVal5 = colVal1.toInt
982
992
983
993
val objectNode : ObjectNode = objectMapper.createObjectNode()
984
994
objectNode.put(colName1, colVal1)
985
995
objectNode.put(colName2, colVal2)
986
996
objectNode.put(colName3, colVal3)
987
997
objectNode.put(colName4, colVal4)
998
+ objectNode.put(colName5, colVal5)
988
999
val schema = StructType (Seq (
989
1000
StructField (colName1, DateType ),
990
1001
StructField (colName2, DateType ),
991
1002
StructField (colName3, DateType ),
992
- StructField (colName4, DateType )))
1003
+ StructField (colName4, DateType ),
1004
+ StructField (colName5, DateType )))
993
1005
val row = defaultRowConverter.fromObjectNodeToRow(schema, objectNode, SchemaConversionModes .Relaxed )
994
1006
val asTime = row.get(0 ).asInstanceOf [Date ]
995
1007
asTime.compareTo(colVal1AsTime) shouldEqual 0
0 commit comments