@@ -18,7 +18,12 @@ import kotlin.reflect.typeOf
18
18
* Assert that we have got the same data that was originally saved on example creation.
19
19
* Example generation project is currently located at https://github.com/Kopilov/arrow_example
20
20
*/
21
- internal fun assertEstimations (exampleFrame : AnyFrame , expectedNullable : Boolean , hasNulls : Boolean ) {
21
+ internal fun assertEstimations (
22
+ exampleFrame : AnyFrame ,
23
+ expectedNullable : Boolean ,
24
+ hasNulls : Boolean ,
25
+ fromParquet : Boolean = false
26
+ ) {
22
27
/* *
23
28
* In [exampleFrame] we get two concatenated batches. To assert the estimations, we should transform frame row number to batch row number
24
29
*/
@@ -129,10 +134,19 @@ internal fun assertEstimations(exampleFrame: AnyFrame, expectedNullable: Boolean
129
134
assertValueOrNull(iBatch(i), element, LocalDate .ofEpochDay(iBatch(i).toLong() * 30 ))
130
135
}
131
136
132
- val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDateTime ?>
133
- datetimeCol.type() shouldBe typeOf<LocalDateTime >().withNullability(expectedNullable)
134
- datetimeCol.forEachIndexed { i, element ->
135
- assertValueOrNull(iBatch(i), element, LocalDateTime .ofEpochSecond(iBatch(i).toLong() * 60 * 60 * 24 * 30 , 0 , ZoneOffset .UTC ))
137
+ if (fromParquet){
138
+ // parquet format have only one type of date: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#date without time
139
+ val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDate ?>
140
+ datetimeCol.type() shouldBe typeOf<LocalDate >().withNullability(expectedNullable)
141
+ datetimeCol.forEachIndexed { i, element ->
142
+ assertValueOrNull(iBatch(i), element, LocalDate .ofEpochDay(iBatch(i).toLong() * 30 ))
143
+ }
144
+ }else {
145
+ val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDateTime ?>
146
+ datetimeCol.type() shouldBe typeOf<LocalDateTime >().withNullability(expectedNullable)
147
+ datetimeCol.forEachIndexed { i, element ->
148
+ assertValueOrNull(iBatch(i), element, LocalDateTime .ofEpochSecond(iBatch(i).toLong() * 60 * 60 * 24 * 30 , 0 , ZoneOffset .UTC ))
149
+ }
136
150
}
137
151
138
152
val timeSecCol = exampleFrame[" time32_seconds" ] as DataColumn <LocalTime ?>
0 commit comments