@@ -159,11 +159,11 @@ private boolean isLazyDecodingSupported(PrimitiveType.PrimitiveTypeName typeName
159
159
boolean isSupported = false ;
160
160
switch (typeName ) {
161
161
case INT32 :
162
- isSupported = originalType != OriginalType .DATE || ! rebaseDateTime ;
162
+ isSupported = originalType != OriginalType .DATE || "CORRECTED" . equals ( datetimeRebaseMode ) ;
163
163
break ;
164
164
case INT64 :
165
165
if (originalType == OriginalType .TIMESTAMP_MICROS ) {
166
- isSupported = ! rebaseDateTime ;
166
+ isSupported = "CORRECTED" . equals ( datetimeRebaseMode ) ;
167
167
} else {
168
168
isSupported = originalType != OriginalType .TIMESTAMP_MILLIS ;
169
169
}
@@ -286,7 +286,7 @@ private void decodeDictionaryIds(
286
286
case INT32 :
287
287
if (column .dataType () == DataTypes .IntegerType ||
288
288
DecimalType .is32BitDecimalType (column .dataType ()) ||
289
- (column .dataType () == DataTypes .DateType && ! rebaseDateTime )) {
289
+ (column .dataType () == DataTypes .DateType && "CORRECTED" . equals ( datetimeRebaseMode ) )) {
290
290
for (int i = rowId ; i < rowId + num ; ++i ) {
291
291
if (!column .isNullAt (i )) {
292
292
column .putInt (i , dictionary .decodeToInt (dictionaryIds .getDictId (i )));
@@ -305,9 +305,13 @@ private void decodeDictionaryIds(
305
305
}
306
306
}
307
307
} else if (column .dataType () == DataTypes .DateType ) {
308
+ boolean failIfRebase = "EXCEPTION" .equals (datetimeRebaseMode );
308
309
for (int i = rowId ; i < rowId + num ; ++i ) {
309
310
if (!column .isNullAt (i )) {
310
311
int julianDays = dictionary .decodeToInt (dictionaryIds .getDictId (i ));
312
+ if (failIfRebase && julianDays < RebaseDateTime .lastSwitchJulianDay ()) {
313
+ throw DataSourceUtils .newRebaseExceptionInRead ("Parquet" );
314
+ }
311
315
int gregorianDays = RebaseDateTime .rebaseJulianToGregorianDays (julianDays );
312
316
column .putInt (i , gregorianDays );
313
317
}
@@ -320,27 +324,31 @@ private void decodeDictionaryIds(
320
324
case INT64 :
321
325
if (column .dataType () == DataTypes .LongType ||
322
326
DecimalType .is64BitDecimalType (column .dataType ()) ||
323
- (originalType == OriginalType .TIMESTAMP_MICROS && ! rebaseDateTime )) {
327
+ (originalType == OriginalType .TIMESTAMP_MICROS && "CORRECTED" . equals ( datetimeRebaseMode ) )) {
324
328
for (int i = rowId ; i < rowId + num ; ++i ) {
325
329
if (!column .isNullAt (i )) {
326
330
column .putLong (i , dictionary .decodeToLong (dictionaryIds .getDictId (i )));
327
331
}
328
332
}
329
333
} else if (originalType == OriginalType .TIMESTAMP_MILLIS ) {
330
- if (rebaseDateTime ) {
334
+ if ("CORRECTED" . equals ( datetimeRebaseMode ) ) {
331
335
for (int i = rowId ; i < rowId + num ; ++i ) {
332
336
if (!column .isNullAt (i )) {
333
- long julianMillis = dictionary .decodeToLong (dictionaryIds .getDictId (i ));
334
- long julianMicros = DateTimeUtils .millisToMicros (julianMillis );
335
- long gregorianMicros = RebaseDateTime .rebaseJulianToGregorianMicros (julianMicros );
336
- column .putLong (i , gregorianMicros );
337
+ long gregorianMillis = dictionary .decodeToLong (dictionaryIds .getDictId (i ));
338
+ column .putLong (i , DateTimeUtils .millisToMicros (gregorianMillis ));
337
339
}
338
340
}
339
341
} else {
342
+ boolean failIfRebase = "EXCEPTION" .equals (datetimeRebaseMode );
340
343
for (int i = rowId ; i < rowId + num ; ++i ) {
341
344
if (!column .isNullAt (i )) {
342
- long gregorianMillis = dictionary .decodeToLong (dictionaryIds .getDictId (i ));
343
- column .putLong (i , DateTimeUtils .millisToMicros (gregorianMillis ));
345
+ long julianMillis = dictionary .decodeToLong (dictionaryIds .getDictId (i ));
346
+ long julianMicros = DateTimeUtils .millisToMicros (julianMillis );
347
+ if (failIfRebase && julianMicros < RebaseDateTime .lastSwitchJulianTs ()) {
348
+ throw DataSourceUtils .newRebaseExceptionInRead ("Parquet" );
349
+ }
350
+ long gregorianMicros = RebaseDateTime .rebaseJulianToGregorianMicros (julianMicros );
351
+ column .putLong (i , gregorianMicros );
344
352
}
345
353
}
346
354
}
0 commit comments