use of com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestRowExpressionDomainTranslator method assertPredicateIsAlwaysFalse.
private void assertPredicateIsAlwaysFalse(RowExpression expression) {
ExtractionResult result = fromPredicate(expression);
assertEquals(result.getRemainingExpression(), TRUE_CONSTANT);
assertTrue(result.getTupleDomain().isNone());
}
use of com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestRowExpressionDomainTranslator method testExpressionConstantFolding.
@Test
public void testExpressionConstantFolding() {
FunctionHandle hex = metadata.getFunctionAndTypeManager().lookupFunction("from_hex", fromTypes(VARCHAR));
RowExpression originalExpression = greaterThan(C_VARBINARY, call("from_hex", hex, VARBINARY, stringLiteral("123456")));
ExtractionResult result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_CONSTANT);
Slice value = Slices.wrappedBuffer(BaseEncoding.base16().decode("123456"));
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_VARBINARY, Domain.create(ValueSet.ofRanges(Range.greaterThan(VARBINARY, value)), false))));
RowExpression expression = toPredicate(result.getTupleDomain());
assertEquals(expression, greaterThan(C_VARBINARY, varbinaryLiteral(value)));
}
Aggregations