Skip to content

Commit

Permalink
LocalTime column writing now uses MILLI precision (int32)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccleva committed Apr 30, 2022
1 parent b55f28e commit af5a5b5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Note that the `ColumnType.SKIP` column type can be used with these options to fi
| DoubleColumn | DOUBLE | |
| StringColumn | BINARY (STRING) | |
| TextColumn | BINARY (STRING) | |
| TimeColumn | INT64 (TIME: NANOS, not UTC) | *Will change to INT32 MILLIS in a future release* |
| TimeColumn | INT32 (TIME: MILLIS, not UTC) | *Changed in v0.11.0, was INT64 (TIME: NANOS, not UTC) before* |
| DateColumn | INT32 (DATE) | |
| DateTimeColumn | INT64 (TIMESTAMP: MILLIS, not UTC) | |
| InstantColumn | INT64 (TIMESTAMP: MILLIS, UTC) | |
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/tlabs/tablesaw/parquet/TableProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ int getDateAsEpochDay(final int colIndex, final int rowIndex) {
return (int) PackedLocalDate.toEpochDay(dateColumns[colIndex].getIntInternal(rowIndex));
}

long getTimeAsNanoOfDay(final int colIndex, final int rowIndex) {
// return PackedLocalTime.getMillisecondOfDay(timeColumns[colIndex].getIntInternal(rowIndex));
return PackedLocalTime.toNanoOfDay(timeColumns[colIndex].getIntInternal(rowIndex));
int getTimeAsMilliOfDay(final int colIndex, final int rowIndex) {
return PackedLocalTime.getMillisecondOfDay(timeColumns[colIndex].getIntInternal(rowIndex));
}

long getInstantAsEpochMilli(final int colIndex, final int rowIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void recordValue(final RecordConsumer recordConsumer, final TableProxy ta
@Override
public void recordValue(final RecordConsumer recordConsumer, final TableProxy tableProxy,
final int colIndex, final int rowNumber) {
recordConsumer.addLong(tableProxy.getTimeAsNanoOfDay(colIndex, rowNumber));
recordConsumer.addInteger(tableProxy.getTimeAsMilliOfDay(colIndex, rowNumber));
}
},
LOCAL_DATE_TIME(ColumnType.LOCAL_DATE_TIME) {
Expand Down Expand Up @@ -158,14 +158,14 @@ abstract public void recordValue(final RecordConsumer recordConsumer, final Tabl
PRIMITIVE_MAPPING.put(ColumnType.LONG, PrimitiveTypeName.INT64);
PRIMITIVE_MAPPING.put(ColumnType.INSTANT, PrimitiveTypeName.INT64);
PRIMITIVE_MAPPING.put(ColumnType.LOCAL_DATE, PrimitiveTypeName.INT32);
PRIMITIVE_MAPPING.put(ColumnType.LOCAL_TIME, PrimitiveTypeName.INT64);
PRIMITIVE_MAPPING.put(ColumnType.LOCAL_TIME, PrimitiveTypeName.INT32);
PRIMITIVE_MAPPING.put(ColumnType.LOCAL_DATE_TIME, PrimitiveTypeName.INT64);
PRIMITIVE_MAPPING.put(ColumnType.STRING, PrimitiveTypeName.BINARY);
PRIMITIVE_MAPPING.put(ColumnType.TEXT, PrimitiveTypeName.BINARY);
ANNOTATION_MAPPING = new HashMap<>();
ANNOTATION_MAPPING.put(ColumnType.SHORT, LogicalTypeAnnotation.intType(16, true));
ANNOTATION_MAPPING.put(ColumnType.LOCAL_DATE, LogicalTypeAnnotation.dateType());
ANNOTATION_MAPPING.put(ColumnType.LOCAL_TIME, LogicalTypeAnnotation.timeType(false, TimeUnit.NANOS));
ANNOTATION_MAPPING.put(ColumnType.LOCAL_TIME, LogicalTypeAnnotation.timeType(false, TimeUnit.MILLIS));
ANNOTATION_MAPPING.put(ColumnType.INSTANT, LogicalTypeAnnotation.timestampType(true, TimeUnit.MILLIS));
ANNOTATION_MAPPING.put(ColumnType.LOCAL_DATE_TIME, LogicalTypeAnnotation.timestampType(false, TimeUnit.MILLIS));
ANNOTATION_MAPPING.put(ColumnType.STRING, LogicalTypeAnnotation.stringType());
Expand Down

0 comments on commit af5a5b5

Please sign in to comment.