@@ -24,7 +24,12 @@ import java.time.LocalTime as JavaLocalTime
24
24
* Assert that we have got the same data that was originally saved on example creation.
25
25
* Example generation project is currently located at https://github.com/Kopilov/arrow_example
26
26
*/
27
- internal fun assertEstimations (exampleFrame : AnyFrame , expectedNullable : Boolean , hasNulls : Boolean ) {
27
+ internal fun assertEstimations (
28
+ exampleFrame : AnyFrame ,
29
+ expectedNullable : Boolean ,
30
+ hasNulls : Boolean ,
31
+ fromParquet : Boolean = false,
32
+ ) {
28
33
/* *
29
34
* In [exampleFrame] we get two concatenated batches. To assert the estimations, we should transform frame row number to batch row number
30
35
*/
@@ -142,16 +147,27 @@ internal fun assertEstimations(exampleFrame: AnyFrame, expectedNullable: Boolean
142
147
assertValueOrNull(iBatch(i), element, JavaLocalDate .ofEpochDay(iBatch(i).toLong() * 30 ).toKotlinLocalDate())
143
148
}
144
149
145
- val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDateTime ?>
146
- datetimeCol.type() shouldBe typeOf<LocalDateTime >().withNullability(expectedNullable)
147
- datetimeCol.forEachIndexed { i, element ->
148
- assertValueOrNull(
149
- rowNumber = iBatch(i),
150
- actual = element,
151
- expected = JavaLocalDateTime
152
- .ofEpochSecond(iBatch(i).toLong() * 60 * 60 * 24 * 30 , 0 , ZoneOffset .UTC )
153
- .toKotlinLocalDateTime(),
154
- )
150
+ if (fromParquet) {
151
+ // parquet format have only one type of date: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#date without time
152
+ val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDate ?>
153
+ datetimeCol.type() shouldBe typeOf<LocalDate >().withNullability(expectedNullable)
154
+ datetimeCol.forEachIndexed { i, element ->
155
+ assertValueOrNull(iBatch(i), element, JavaLocalDate .ofEpochDay(iBatch(i).toLong() * 30 ).toKotlinLocalDate())
156
+ }
157
+ } else {
158
+ val datetimeCol = exampleFrame[" date64" ] as DataColumn <LocalDateTime ?>
159
+ datetimeCol.type() shouldBe typeOf<LocalDateTime >().withNullability(expectedNullable)
160
+ datetimeCol.forEachIndexed { i, element ->
161
+ assertValueOrNull(
162
+ rowNumber = iBatch(i),
163
+ actual = element,
164
+ expected = JavaLocalDateTime .ofEpochSecond(
165
+ iBatch(i).toLong() * 60 * 60 * 24 * 30 ,
166
+ 0 ,
167
+ ZoneOffset .UTC ,
168
+ ).toKotlinLocalDateTime(),
169
+ )
170
+ }
155
171
}
156
172
157
173
val timeSecCol = exampleFrame[" time32_seconds" ] as DataColumn <LocalTime ?>
0 commit comments