Skip to content

Commit

Permalink
Extract ICEBERG_LONG_TYPE constant
Browse files Browse the repository at this point in the history
  • Loading branch information
joejensen authored and ebyhr committed Jul 17, 2023
1 parent 8af0d22 commit f87aafe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public final class ColumnReaders
{
public static final String ICEBERG_BINARY_TYPE = "iceberg.binary-type";
public static final String ICEBERG_LONG_TYPE = "iceberg.long-type";

private ColumnReaders() {}

Expand All @@ -47,7 +48,7 @@ public static ColumnReader createColumnReader(
{
if (type instanceof TimeType) {
if (!type.equals(TIME_MICROS) || column.getColumnType() != LONG ||
!"TIME".equals(column.getAttributes().get("iceberg.long-type"))) {
!"TIME".equals(column.getAttributes().get(ICEBERG_LONG_TYPE))) {
throw invalidStreamType(column, type);
}
return new TimeColumnReader(type, column, memoryContext.newLocalMemoryContext(ColumnReaders.class.getSimpleName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.orc.metadata.OrcType.OrcTypeKind.LONG;
import static io.trino.orc.reader.ColumnReaders.ICEBERG_LONG_TYPE;
import static java.lang.Math.toIntExact;
import static java.util.Objects.requireNonNull;

Expand All @@ -55,7 +56,7 @@ public static ColumnWriter createColumnWriter(
if (type instanceof TimeType timeType) {
checkArgument(timeType.getPrecision() == 6, "%s not supported for ORC writer", type);
checkArgument(orcType.getOrcTypeKind() == LONG, "wrong ORC type %s for type %s", orcType, type);
checkArgument("TIME".equals(orcType.getAttributes().get("iceberg.long-type")), "wrong attributes %s for type %s", orcType.getAttributes(), type);
checkArgument("TIME".equals(orcType.getAttributes().get(ICEBERG_LONG_TYPE)), "wrong attributes %s for type %s", orcType.getAttributes(), type);
return new TimeColumnWriter(columnId, type, compression, bufferSize, () -> new IntegerStatisticsBuilder(bloomFilterBuilder.get()));
}
switch (orcType.getOrcTypeKind()) {
Expand Down

0 comments on commit f87aafe

Please sign in to comment.