@@ -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
*/
@@ -136,14 +141,23 @@ internal fun assertEstimations(exampleFrame: AnyFrame, expectedNullable: Boolean
136
141
assertValueOrNull(iBatch(i), element, LocalDate .ofEpochDay(iBatch(i).toLong() * 30 ))
137
142
}
138
143
139
- val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDateTime ?>
140
- datetimeCol.type() shouldBe typeOf<LocalDateTime >().withNullability(expectedNullable)
141
- datetimeCol.forEachIndexed { i, element ->
142
- assertValueOrNull(
143
- rowNumber = iBatch(i),
144
- actual = element,
145
- expected = LocalDateTime .ofEpochSecond(iBatch(i).toLong() * 60 * 60 * 24 * 30 , 0 , ZoneOffset .UTC ),
146
- )
144
+ if (fromParquet) {
145
+ // parquet format have only one type of date: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#date without time
146
+ val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDate ?>
147
+ datetimeCol.type() shouldBe typeOf<LocalDate >().withNullability(expectedNullable)
148
+ datetimeCol.forEachIndexed { i, element ->
149
+ assertValueOrNull(iBatch(i), element, LocalDate .ofEpochDay(iBatch(i).toLong() * 30 ))
150
+ }
151
+ } else {
152
+ val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDateTime ?>
153
+ datetimeCol.type() shouldBe typeOf<LocalDateTime >().withNullability(expectedNullable)
154
+ datetimeCol.forEachIndexed { i, element ->
155
+ assertValueOrNull(
156
+ rowNumber = iBatch(i),
157
+ actual = element,
158
+ expected = LocalDateTime .ofEpochSecond(iBatch(i).toLong() * 60 * 60 * 24 * 30 , 0 , ZoneOffset .UTC ),
159
+ )
160
+ }
147
161
}
148
162
149
163
val timeSecCol = exampleFrame[" time32_seconds" ] as DataColumn <LocalTime ?>
0 commit comments