Skip to content

Commit

Permalink
Remove redundant cast to SortedRangeSet
Browse files Browse the repository at this point in the history
Use `ValueSet` API to access ranges, without need to do a cast.
  • Loading branch information
findepi committed Nov 23, 2021
1 parent c68bda7 commit 646591b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import io.airlift.slice.Slice;
import io.trino.spi.predicate.Domain;
import io.trino.spi.predicate.Range;
import io.trino.spi.predicate.SortedRangeSet;
import io.trino.spi.predicate.TupleDomain;
import io.trino.spi.predicate.ValueSet;
import io.trino.spi.type.ArrayType;
Expand Down Expand Up @@ -52,6 +51,7 @@
import static io.trino.spi.type.UuidType.trinoUuidToJavaUuid;
import static java.lang.Float.intBitsToFloat;
import static java.lang.Math.toIntExact;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static org.apache.iceberg.expressions.Expressions.alwaysFalse;
import static org.apache.iceberg.expressions.Expressions.alwaysTrue;
Expand Down Expand Up @@ -112,8 +112,8 @@ private static Expression toIcebergExpression(String columnName, Type type, Doma
expression = isNull(columnName);
}

if (domainValues instanceof SortedRangeSet) {
List<Range> orderedRanges = ((SortedRangeSet) domainValues).getOrderedRanges();
if (type.isOrderable()) {
List<Range> orderedRanges = domainValues.getRanges().getOrderedRanges();
expression = firstNonNull(expression, alwaysFalse());

for (Range range : orderedRanges) {
Expand All @@ -122,7 +122,7 @@ private static Expression toIcebergExpression(String columnName, Type type, Doma
return expression;
}

throw new VerifyException("Did not expect a domain value set other than SortedRangeSet but got " + domainValues.getClass().getSimpleName());
throw new VerifyException(format("Unsupported type %s with domain values %s", type, domain));
}

private static Expression toIcebergExpression(String columnName, Range range)
Expand Down

0 comments on commit 646591b

Please sign in to comment.