Skip to content

Commit f426cb2

Browse files
add timezone logic to batch readers, tests passing
1 parent a191c99 commit f426cb2

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/Int64TimeAndTimestampMicrosFlatBatchReader.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.facebook.presto.common.block.Block;
1717
import com.facebook.presto.common.block.LongArrayBlock;
1818
import com.facebook.presto.common.block.RunLengthEncodedBlock;
19+
import com.facebook.presto.common.type.TimestampWithTimeZoneType;
1920
import com.facebook.presto.parquet.ColumnReader;
2021
import com.facebook.presto.parquet.DataPage;
2122
import com.facebook.presto.parquet.DictionaryPage;
@@ -163,7 +164,12 @@ private ColumnChunk readWithNull()
163164
totalNonNullCount += nonNullCount;
164165

165166
if (nonNullCount > 0) {
166-
valuesDecoder.readNext(values, startOffset, nonNullCount);
167+
if (field.getType() instanceof TimestampWithTimeZoneType) {
168+
valuesDecoder.readNextWithTimezone(values, startOffset, nonNullCount);
169+
}
170+
else {
171+
valuesDecoder.readNext(values, startOffset, nonNullCount);
172+
}
167173

168174
int valueDestinationIndex = startOffset + chunkSize - 1;
169175
int valueSourceIndex = startOffset + nonNullCount - 1;
@@ -211,7 +217,12 @@ private ColumnChunk readWithoutNull()
211217

212218
int chunkSize = Math.min(remainingCountInPage, remainingInBatch);
213219

214-
valuesDecoder.readNext(values, startOffset, chunkSize);
220+
if (field.getType() instanceof TimestampWithTimeZoneType) {
221+
valuesDecoder.readNextWithTimezone(values, startOffset, chunkSize);
222+
}
223+
else {
224+
valuesDecoder.readNext(values, startOffset, chunkSize);
225+
}
215226
startOffset += chunkSize;
216227
remainingInBatch -= chunkSize;
217228
remainingCountInPage -= chunkSize;

presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/Int64TimeAndTimestampMicrosNestedBatchReader.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.facebook.presto.common.block.Block;
1717
import com.facebook.presto.common.block.LongArrayBlock;
1818
import com.facebook.presto.common.block.RunLengthEncodedBlock;
19+
import com.facebook.presto.common.type.TimestampWithTimeZoneType;
1920
import com.facebook.presto.parquet.RichColumnDescriptor;
2021
import com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int64TimeAndTimestampMicrosValuesDecoder;
2122
import com.facebook.presto.parquet.reader.ColumnChunk;
@@ -64,7 +65,12 @@ protected ColumnChunk readNestedWithNull()
6465
boolean[] isNull = new boolean[newBatchSize];
6566
int offset = 0;
6667
for (ValuesDecoderContext valuesDecoderContext : definitionLevelDecodingContext.getValuesDecoderContexts()) {
67-
((Int64TimeAndTimestampMicrosValuesDecoder) valuesDecoderContext.getValuesDecoder()).readNext(values, offset, valuesDecoderContext.getNonNullCount());
68+
if (field.getType() instanceof TimestampWithTimeZoneType) {
69+
((Int64TimeAndTimestampMicrosValuesDecoder) valuesDecoderContext.getValuesDecoder()).readNextWithTimezone(values, offset, valuesDecoderContext.getNonNullCount());
70+
}
71+
else {
72+
((Int64TimeAndTimestampMicrosValuesDecoder) valuesDecoderContext.getValuesDecoder()).readNext(values, offset, valuesDecoderContext.getNonNullCount());
73+
}
6874

6975
int valueDestinationIndex = offset + valuesDecoderContext.getValueCount() - 1;
7076
int valueSourceIndex = offset + valuesDecoderContext.getNonNullCount() - 1;
@@ -112,7 +118,12 @@ protected ColumnChunk readNestedNoNull()
112118
long[] values = new long[newBatchSize];
113119
int offset = 0;
114120
for (ValuesDecoderContext valuesDecoderContext : definitionLevelDecodingContext.getValuesDecoderContexts()) {
115-
((Int64TimeAndTimestampMicrosValuesDecoder) valuesDecoderContext.getValuesDecoder()).readNext(values, offset, valuesDecoderContext.getNonNullCount());
121+
if (field.getType() instanceof TimestampWithTimeZoneType) {
122+
((Int64TimeAndTimestampMicrosValuesDecoder) valuesDecoderContext.getValuesDecoder()).readNextWithTimezone(values, offset, valuesDecoderContext.getNonNullCount());
123+
}
124+
else {
125+
((Int64TimeAndTimestampMicrosValuesDecoder) valuesDecoderContext.getValuesDecoder()).readNext(values, offset, valuesDecoderContext.getNonNullCount());
126+
}
116127
offset += valuesDecoderContext.getValueCount();
117128
}
118129

0 commit comments

Comments
 (0)