Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PARQUET-2382: Remove the deprecated OriginalType #1194

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -145,16 +145,6 @@ protected LogicalTypeAnnotation fromString(List<String> params) {
protected abstract LogicalTypeAnnotation fromString(List<String> params);
}

/**
* Convert this logical type to old logical type representation in parquet-mr (if there's any).
* Those logical type implementations, which don't have a corresponding mapping should return null.
*
* API should be considered private
*
* @return the OriginalType representation of the new logical type, or null if there's none
*/
public abstract OriginalType toOriginalType();

/**
* Visits this logical type with the given visitor
*
Expand Down Expand Up @@ -311,16 +301,6 @@ public static class StringLogicalTypeAnnotation extends LogicalTypeAnnotation {
private StringLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.UTF8;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -354,16 +334,6 @@ public static class MapLogicalTypeAnnotation extends LogicalTypeAnnotation {
private MapLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.MAP;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -392,16 +362,6 @@ public static class ListLogicalTypeAnnotation extends LogicalTypeAnnotation {
private ListLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.LIST;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -430,16 +390,6 @@ public static class EnumLogicalTypeAnnotation extends LogicalTypeAnnotation {
private EnumLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.ENUM;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -486,16 +436,6 @@ public int getScale() {
return scale;
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.DECIMAL;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -543,16 +483,6 @@ public static class DateLogicalTypeAnnotation extends LogicalTypeAnnotation {
private DateLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.DATE;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -595,23 +525,6 @@ private TimeLogicalTypeAnnotation(boolean isAdjustedToUTC, TimeUnit unit) {
this.unit = unit;
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
switch (unit) {
case MILLIS:
return OriginalType.TIME_MILLIS;
case MICROS:
return OriginalType.TIME_MICROS;
default:
return null;
}
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -678,23 +591,6 @@ private TimestampLogicalTypeAnnotation(boolean isAdjustedToUTC, TimeUnit unit) {
this.unit = unit;
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
switch (unit) {
case MILLIS:
return OriginalType.TIMESTAMP_MILLIS;
case MICROS:
return OriginalType.TIMESTAMP_MICROS;
default:
return null;
}
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -768,27 +664,6 @@ private IntLogicalTypeAnnotation(int bitWidth, boolean isSigned) {
this.isSigned = isSigned;
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
switch (bitWidth) {
case 8:
return isSigned ? OriginalType.INT_8 : OriginalType.UINT_8;
case 16:
return isSigned ? OriginalType.INT_16 : OriginalType.UINT_16;
case 32:
return isSigned ? OriginalType.INT_32 : OriginalType.UINT_32;
case 64:
return isSigned ? OriginalType.INT_64 : OriginalType.UINT_64;
default:
return null;
}
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -844,16 +719,6 @@ public static class JsonLogicalTypeAnnotation extends LogicalTypeAnnotation {
private JsonLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.JSON;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -887,16 +752,6 @@ public static class BsonLogicalTypeAnnotation extends LogicalTypeAnnotation {
private BsonLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.BSON;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -931,17 +786,6 @@ public static class UUIDLogicalTypeAnnotation extends LogicalTypeAnnotation {
private UUIDLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
// No OriginalType for UUID
return null;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -971,16 +815,6 @@ public static LogicalTypeAnnotation getInstance() {
private IntervalLogicalTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.INTERVAL;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down Expand Up @@ -1026,16 +860,6 @@ public static MapKeyValueTypeAnnotation getInstance() {
private MapKeyValueTypeAnnotation() {
}

/**
* API Should be considered private
*
* @return the original type
*/
@Override
public OriginalType toOriginalType() {
return OriginalType.MAP_KEY_VALUE;
}

@Override
public <T> Optional<T> accept(LogicalTypeAnnotationVisitor<T> logicalTypeAnnotationVisitor) {
return logicalTypeAnnotationVisitor.visit(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,6 @@ public LogicalTypeAnnotation getLogicalTypeAnnotation() {
return logicalTypeAnnotation;
}

/**
* @return the original type (LIST, MAP, ...)
*/
public OriginalType getOriginalType() {
return logicalTypeAnnotation == null ? null : logicalTypeAnnotation.toOriginalType();
}

/**
* @return if this is a primitive type
*/
Expand Down
23 changes: 6 additions & 17 deletions parquet-column/src/main/java/org/apache/parquet/schema/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ public P named(String name) {
"[BUG] Parent and return type are null: must override named");
}
}

protected OriginalType getOriginalType () {
return logicalTypeAnnotation == null ? null : logicalTypeAnnotation.toOriginalType();
}
}

public abstract static class
Expand Down Expand Up @@ -441,6 +437,9 @@ protected PrimitiveType build(String name) {
}

DecimalMetadata meta = decimalMetadata();
if (logicalTypeAnnotation instanceof LogicalTypeAnnotation.DecimalLogicalTypeAnnotation) {
this.logicalTypeAnnotation = LogicalTypeAnnotation.fromOriginalType(OriginalType.DECIMAL, meta);
}

// validate type annotations and required metadata
if (logicalTypeAnnotation != null) {
Expand Down Expand Up @@ -580,11 +579,7 @@ private Optional<Boolean> checkInt64PrimitiveType(LogicalTypeAnnotation logicalT
}).orElseThrow(() -> new IllegalStateException(logicalTypeAnnotation + " can not be applied to a primitive type"));
}

if (newLogicalTypeSet) {
return new PrimitiveType(repetition, primitiveType, length, name, logicalTypeAnnotation, id, columnOrder);
} else {
return new PrimitiveType(repetition, primitiveType, length, name, getOriginalType(), meta, id, columnOrder);
}
return new PrimitiveType(repetition, primitiveType, length, name, logicalTypeAnnotation, id, columnOrder);
}

private static long maxPrecision(int numBytes) {
Expand All @@ -596,7 +591,6 @@ private static long maxPrecision(int numBytes) {
}

protected DecimalMetadata decimalMetadata() {
DecimalMetadata meta = null;
if (logicalTypeAnnotation instanceof LogicalTypeAnnotation.DecimalLogicalTypeAnnotation) {
LogicalTypeAnnotation.DecimalLogicalTypeAnnotation decimalType = (LogicalTypeAnnotation.DecimalLogicalTypeAnnotation) logicalTypeAnnotation;
if (newLogicalTypeSet) {
Expand All @@ -617,9 +611,8 @@ protected DecimalMetadata decimalMetadata() {
"Invalid DECIMAL scale: %s", this.scale);
Preconditions.checkArgument(this.scale <= precision,
"Invalid DECIMAL scale: cannot be greater than precision");
meta = new DecimalMetadata(precision, scale);
}
return meta;
return new DecimalMetadata(precision, scale);
}
}

Expand Down Expand Up @@ -772,11 +765,7 @@ public THIS addFields(Type... types) {

@Override
protected GroupType build(String name) {
if (newLogicalTypeSet) {
return new GroupType(repetition, name, logicalTypeAnnotation, fields, id);
} else {
return new GroupType(repetition, name, getOriginalType(), fields, id);
}
return new GroupType(repetition, name, logicalTypeAnnotation, fields, id);
}

public MapBuilder<THIS> map(
Expand Down
Loading