public static Domain all(Type type) { return new Domain(ValueSet.all(type), true); }
public static Domain notNull(Type type) { return new Domain(ValueSet.all(type), false); }
@Test public void testFromValueSetAll() { PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.all(HYPER_LOG_LOG)); assertNotNull(thriftValueSet.getAllOrNoneValueSet()); assertTrue(thriftValueSet.getAllOrNoneValueSet().isAll()); }
private static <F, T extends Comparable<T>> Domain createDomain(Type type, boolean hasNullValue, RangeStatistics<F> rangeStatistics, Function<F, T> function) { F min = rangeStatistics.getMin(); F max = rangeStatistics.getMax(); if (min != null && max != null) { return Domain.create(ValueSet.ofRanges(Range.range(type, function.apply(min), true, function.apply(max), true)), hasNullValue); } if (max != null) { return Domain.create(ValueSet.ofRanges(Range.lessThanOrEqual(type, function.apply(max))), hasNullValue); } if (min != null) { return Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(type, function.apply(min))), hasNullValue); } return Domain.create(ValueSet.all(type), hasNullValue); }
@Test public void testFromValueSetAll() { PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.all(HYPER_LOG_LOG)); assertNotNull(thriftValueSet.getAllOrNoneValueSet()); assertTrue(thriftValueSet.getAllOrNoneValueSet().isAll()); }
private static <F, T extends Comparable<T>> Domain createDomain(Type type, boolean hasNullValue, RangeStatistics<F> rangeStatistics, Function<F, T> function) { F min = rangeStatistics.getMin(); F max = rangeStatistics.getMax(); if (min != null && max != null) { return Domain.create(ValueSet.ofRanges(Range.range(type, function.apply(min), true, function.apply(max), true)), hasNullValue); } if (max != null) { return Domain.create(ValueSet.ofRanges(Range.lessThanOrEqual(type, function.apply(max))), hasNullValue); } if (min != null) { return Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(type, function.apply(min))), hasNullValue); } return Domain.create(ValueSet.all(type), hasNullValue); }
@Test public void testFromValueSetAll() { PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.all(JSON)); assertNotNull(thriftValueSet.getEquatableValueSet()); assertFalse(thriftValueSet.getEquatableValueSet().isWhiteList()); assertTrue(thriftValueSet.getEquatableValueSet().getValues().isEmpty()); }
@Test public void testFromValueSetAll() { PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.all(JSON)); assertNotNull(thriftValueSet.getEquatableValueSet()); assertFalse(thriftValueSet.getEquatableValueSet().isWhiteList()); assertTrue(thriftValueSet.getEquatableValueSet().getValues().isEmpty()); }
@Test public void testUncomparableAll() { Domain domain = Domain.all(HYPER_LOG_LOG); assertFalse(domain.isNone()); assertTrue(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isOnlyNull()); assertTrue(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.all(HYPER_LOG_LOG)); assertEquals(domain.getType(), HYPER_LOG_LOG); assertTrue(domain.includesNullableValue(Slices.EMPTY_SLICE)); assertTrue(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.none(HYPER_LOG_LOG)); }
@Test public void testEquatableNotNull() { Domain domain = Domain.notNull(ID); assertFalse(domain.isNone()); assertFalse(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isOnlyNull()); assertFalse(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.all(ID)); assertEquals(domain.getType(), ID); assertTrue(domain.includesNullableValue(0L)); assertFalse(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.onlyNull(ID)); }
@Test public void testEquatableAll() { Domain domain = Domain.all(ID); assertFalse(domain.isNone()); assertTrue(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isOnlyNull()); assertTrue(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.all(ID)); assertEquals(domain.getType(), ID); assertTrue(domain.includesNullableValue(0L)); assertTrue(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.none(ID)); }
@Test public void testEquatableNotNull() { Domain domain = Domain.notNull(ID); assertFalse(domain.isNone()); assertFalse(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isOnlyNull()); assertFalse(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.all(ID)); assertEquals(domain.getType(), ID); assertTrue(domain.includesNullableValue(0L)); assertFalse(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.onlyNull(ID)); }
@Test public void testEquatableAll() { Domain domain = Domain.all(ID); assertFalse(domain.isNone()); assertTrue(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isOnlyNull()); assertTrue(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.all(ID)); assertEquals(domain.getType(), ID); assertTrue(domain.includesNullableValue(0L)); assertTrue(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.none(ID)); }
@Test public void testUncomparableNotNull() { Domain domain = Domain.notNull(HYPER_LOG_LOG); assertFalse(domain.isNone()); assertFalse(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isOnlyNull()); assertFalse(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.all(HYPER_LOG_LOG)); assertEquals(domain.getType(), HYPER_LOG_LOG); assertTrue(domain.includesNullableValue(Slices.EMPTY_SLICE)); assertFalse(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.onlyNull(HYPER_LOG_LOG)); }
@Test public void testFromValueSetAll() { PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.all(BIGINT)); assertNotNull(thriftValueSet.getRangeValueSet()); assertEquals(thriftValueSet.getRangeValueSet().getRanges(), ImmutableList.of( new PrestoThriftRange(new PrestoThriftMarker(null, ABOVE), new PrestoThriftMarker(null, BELOW)))); }
@Test public void testFromValueSetAll() { PrestoThriftValueSet thriftValueSet = fromValueSet(ValueSet.all(BIGINT)); assertNotNull(thriftValueSet.getRangeValueSet()); assertEquals(thriftValueSet.getRangeValueSet().getRanges(), ImmutableList.of( new PrestoThriftRange(new PrestoThriftMarker(null, ABOVE), new PrestoThriftMarker(null, BELOW)))); }
@Test public void testBigint() throws ParquetCorruptionException { String column = "BigintColumn"; assertEquals(getDomain(BIGINT, 0, null, ID, column, true), all(BIGINT)); assertEquals(getDomain(BIGINT, 10, longColumnStats(100L, 100L), ID, column, true), singleValue(BIGINT, 100L)); assertEquals(getDomain(BIGINT, 10, longColumnStats(0L, 100L), ID, column, true), create(ValueSet.ofRanges(range(BIGINT, 0L, true, 100L, true)), false)); // ignore corrupted statistics assertEquals(getDomain(BIGINT, 10, longColumnStats(100L, 0L), ID, column, false), create(ValueSet.all(BIGINT), false)); // fail on corrupted statistics assertThatExceptionOfType(ParquetCorruptionException.class) .isThrownBy(() -> getDomain(BIGINT, 10, longColumnStats(100L, 10L), ID, column, true)) .withMessage("Corrupted statistics for column \"BigintColumn\" in Parquet file \"testFile\": [min: 100, max: 10, num_nulls: 0]"); }
@Test public void testDouble() throws ParquetCorruptionException { String column = "DoubleColumn"; assertEquals(getDomain(DOUBLE, 0, null, ID, column, true), all(DOUBLE)); assertEquals(getDomain(DOUBLE, 10, doubleColumnStats(42.24, 42.24), ID, column, true), singleValue(DOUBLE, 42.24)); assertEquals(getDomain(DOUBLE, 10, doubleColumnStats(3.3, 42.24), ID, column, true), create(ValueSet.ofRanges(range(DOUBLE, 3.3, true, 42.24, true)), false)); // ignore corrupted statistics assertEquals(getDomain(DOUBLE, 10, doubleColumnStats(42.24, 3.3), ID, column, false), create(ValueSet.all(DOUBLE), false)); // fail on corrupted statistics assertThatExceptionOfType(ParquetCorruptionException.class) .isThrownBy(() -> getDomain(DOUBLE, 10, doubleColumnStats(42.24, 3.3), ID, column, true)) .withMessage("Corrupted statistics for column \"DoubleColumn\" in Parquet file \"testFile\": [min: 42.24000, max: 3.30000, num_nulls: 0]"); }
@Test public void testDate() throws ParquetCorruptionException { String column = "DateColumn"; assertEquals(getDomain(DATE, 0, null, ID, column, true), all(DATE)); assertEquals(getDomain(DATE, 10, intColumnStats(100, 100), ID, column, true), singleValue(DATE, 100L)); assertEquals(getDomain(DATE, 10, intColumnStats(0, 100), ID, column, true), create(ValueSet.ofRanges(range(DATE, 0L, true, 100L, true)), false)); // ignore corrupted statistics assertEquals(getDomain(DATE, 10, intColumnStats(200, 100), ID, column, false), create(ValueSet.all(DATE), false)); // fail on corrupted statistics assertThatExceptionOfType(ParquetCorruptionException.class) .isThrownBy(() -> getDomain(DATE, 10, intColumnStats(200, 100), ID, column, true)) .withMessage("Corrupted statistics for column \"DateColumn\" in Parquet file \"testFile\": [min: 200, max: 100, num_nulls: 0]"); }
@Test public void testSmallint() throws ParquetCorruptionException { String column = "SmallintColumn"; assertEquals(getDomain(SMALLINT, 0, null, ID, column, true), all(SMALLINT)); assertEquals(getDomain(SMALLINT, 10, longColumnStats(100, 100), ID, column, true), singleValue(SMALLINT, 100L)); assertEquals(getDomain(SMALLINT, 10, longColumnStats(0, 100), ID, column, true), create(ValueSet.ofRanges(range(SMALLINT, 0L, true, 100L, true)), false)); assertEquals(getDomain(SMALLINT, 20, longColumnStats(0, 2147483648L), ID, column, true), notNull(SMALLINT)); // ignore corrupted statistics assertEquals(getDomain(SMALLINT, 10, longColumnStats(2147483648L, 0), ID, column, false), create(ValueSet.all(SMALLINT), false)); // fail on corrupted statistics assertThatExceptionOfType(ParquetCorruptionException.class) .isThrownBy(() -> getDomain(SMALLINT, 10, longColumnStats(2147483648L, 10), ID, column, true)) .withMessage("Corrupted statistics for column \"SmallintColumn\" in Parquet file \"testFile\": [min: 2147483648, max: 10, num_nulls: 0]"); }