Skip to content

Commit

Permalink
Keep same domain in simplify() when already simple
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Oct 2, 2020
1 parent 870c075 commit b69ed98
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions presto-spi/src/main/java/io/prestosql/spi/predicate/Domain.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public Domain simplify()

public Domain simplify(int threshold)
{
ValueSet simplifiedValueSet = values.getValuesProcessor().<Optional<ValueSet>>transform(
Optional<ValueSet> simplifiedValueSet = values.getValuesProcessor().transform(
ranges -> {
if (ranges.getRangeCount() <= threshold) {
return Optional.empty();
Expand All @@ -296,9 +296,11 @@ public Domain simplify(int threshold)
}
return Optional.of(ValueSet.all(values.getType()));
},
allOrNone -> Optional.empty())
.orElse(values);
return Domain.create(simplifiedValueSet, nullAllowed);
allOrNone -> Optional.empty());
if (simplifiedValueSet.isEmpty()) {
return this;
}
return Domain.create(simplifiedValueSet.get(), nullAllowed);
}

@Override
Expand Down

0 comments on commit b69ed98

Please sign in to comment.