Skip to content

Commit

Permalink
Fix bug for domain with lower unbounded range
Browse files Browse the repository at this point in the history
  • Loading branch information
nileema committed Oct 5, 2015
1 parent 6c4c536 commit 90e7efd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -122,14 +122,13 @@ private String toPredicate(int columnIndex, Domain domain)
List<Comparable<?>> singleValues = new ArrayList<>();
for (Range range : domain.getRanges()) {
checkState(!range.isAll()); // Already checked
Comparable<?> lowValue = range.getLow().getValue();
if (range.isSingleValue()) {
singleValues.add(lowValue);
singleValues.add(range.getLow().getValue());
}
else {
List<String> rangeConjuncts = new ArrayList<>();
if (!range.getLow().isLowerUnbounded()) {
Object bindValue = getBindValue(columnIndex, lowValue);
Object bindValue = getBindValue(columnIndex, range.getLow().getValue());
switch (range.getLow().getBound()) {
case ABOVE:
rangeConjuncts.add(toBindPredicate(columnName, ">"));
Expand All @@ -146,8 +145,7 @@ private String toPredicate(int columnIndex, Domain domain)
}
}
if (!range.getHigh().isUpperUnbounded()) {
Comparable<?> highValue = range.getHigh().getValue();
Object bindValue = getBindValue(columnIndex, highValue);
Object bindValue = getBindValue(columnIndex, range.getHigh().getValue());
switch (range.getHigh().getBound()) {
case ABOVE:
throw new IllegalStateException("High Marker should never use ABOVE bound: " + range);
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.facebook.presto.spi.Domain;
import com.facebook.presto.spi.RecordCursor;
import com.facebook.presto.spi.SchemaTableName;
import com.facebook.presto.spi.SortedRangeSet;
import com.facebook.presto.spi.TupleDomain;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.testing.MaterializedRow;
Expand All @@ -47,6 +48,7 @@

import static com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder;
import static com.facebook.presto.raptor.systemtables.ShardMetadataRecordCursor.SHARD_METADATA;
import static com.facebook.presto.spi.Range.lessThanOrEqual;
import static com.facebook.presto.spi.type.BigintType.BIGINT;
import static com.facebook.presto.spi.type.DateType.DATE;
import static com.facebook.presto.spi.type.DoubleType.DOUBLE;
Expand Down Expand Up @@ -127,7 +129,7 @@ public void testSimple()
TupleDomain<Integer> tupleDomain = TupleDomain.withColumnDomains(
ImmutableMap.<Integer, Domain>builder()
.put(0, Domain.singleValue(schema))
.put(1, Domain.singleValue(table))
.put(1, Domain.create(SortedRangeSet.of(lessThanOrEqual(table)), true))
.build());

List<MaterializedRow> actual;
Expand Down

0 comments on commit 90e7efd

Please sign in to comment.