Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public static TypeDescription toOrcType(DataType type) {
case DATE:
return TypeDescription.createDate();
case TIMESTAMP_WITHOUT_TIME_ZONE:
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return TypeDescription.createTimestamp();
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return TypeDescription.createTimestampInstant();
case ARRAY:
ArrayType arrayType = (ArrayType) type;
return TypeDescription.createList(toOrcType(arrayType.getElementType()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ private static Type convertToParquetType(
case TIMESTAMP_WITHOUT_TIME_ZONE:
TimestampType timestampType = (TimestampType) type;
return createTimestampWithLogicalType(
name, timestampType.getPrecision(), repetition);
name, timestampType.getPrecision(), repetition, false);
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
LocalZonedTimestampType localZonedTimestampType = (LocalZonedTimestampType) type;
return createTimestampWithLogicalType(
name, localZonedTimestampType.getPrecision(), repetition);
name, localZonedTimestampType.getPrecision(), repetition, true);
case ARRAY:
ArrayType arrayType = (ArrayType) type;
return ConversionPatterns.listOfElements(
Expand Down Expand Up @@ -151,13 +151,21 @@ private static Type convertToParquetType(
}

private static Type createTimestampWithLogicalType(
String name, int precision, Type.Repetition repetition) {
String name, int precision, Type.Repetition repetition, boolean isAdjustToUTC) {
if (precision <= 3) {
return Types.primitive(INT64, repetition).as(OriginalType.TIMESTAMP_MILLIS).named(name);
return Types.primitive(INT64, repetition)
.as(
LogicalTypeAnnotation.timestampType(
isAdjustToUTC, LogicalTypeAnnotation.TimeUnit.MILLIS))
.named(name);
} else if (precision > 6) {
return Types.primitive(PrimitiveType.PrimitiveTypeName.INT96, repetition).named(name);
} else {
return Types.primitive(INT64, repetition).as(OriginalType.TIMESTAMP_MICROS).named(name);
return Types.primitive(INT64, repetition)
.as(
LogicalTypeAnnotation.timestampType(
isAdjustToUTC, LogicalTypeAnnotation.TimeUnit.MICROS))
.named(name);
}
}

Expand Down