use of com.facebook.presto.hive.HiveCoercer.VarcharToIntegerNumberCoercer in project presto by prestodb.
the class TestCoercingFilters method testVarcharToInteger.
@Test
public void testVarcharToInteger() {
TupleDomainFilter filter = BigintRange.of(100, Integer.MAX_VALUE, false);
HiveCoercer coercer = new VarcharToIntegerNumberCoercer(VARCHAR, INTEGER);
TupleDomainFilter coercingFilter = coercer.toCoercingFilter(filter, new Subfield("c"));
assertTrue(coercingFilter.testLength(1));
assertTrue(coercingFilter.testLength(2));
assertTrue(coercingFilter.testLength(3));
assertTrue(coercingFilter.testBytes("100".getBytes(), 0, 3));
assertTrue(coercingFilter.testBytes("145".getBytes(), 0, 3));
assertTrue(coercingFilter.testBytes("2147483647".getBytes(), 0, 10));
assertFalse(coercingFilter.testBytes("50".getBytes(), 0, 2));
assertFalse(coercingFilter.testBytes("-50".getBytes(), 0, 3));
// parsing error
assertFalse(coercingFilter.testBytes("abc".getBytes(), 0, 3));
// out of range
assertFalse(coercingFilter.testBytes("2147483648".getBytes(), 0, 10));
assertFalse(coercingFilter.testNull());
}
Aggregations