Refine search
@Test public void testEmptyBuildSql() throws SQLException { TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( columns.get(0), Domain.all(BIGINT), columns.get(1), Domain.onlyNull(DOUBLE))); Connection connection = database.getConnection(); try (PreparedStatement preparedStatement = new QueryBuilder("\"").buildSql(jdbcClient, connection, "", "", "test_table", columns, tupleDomain, Optional.empty()); ResultSet resultSet = preparedStatement.executeQuery()) { assertEquals(resultSet.next(), false); } }
@Test public void testIsAll() { assertTrue(TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of()).isAll()); assertFalse(TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.singleValue(BIGINT, 0L))).isAll()); assertTrue(TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.all(BIGINT))).isAll()); assertFalse(TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.singleValue(BIGINT, 0L), B, Domain.all(BIGINT))).isAll()); }
@Test public void testAll() { assertTrue(TupleDomain.all().isAll()); assertEquals(TupleDomain.<ColumnHandle>all(), TupleDomain.withColumnDomains(ImmutableMap.of( A, Domain.all(BIGINT)))); assertEquals(TupleDomain.<ColumnHandle>all(), TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of())); }
@Test public void testIsNone() { assertFalse(TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of()).isNone()); assertFalse(TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.singleValue(BIGINT, 0L))).isNone()); assertTrue(TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.none(BIGINT))).isNone()); assertFalse(TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.all(BIGINT))).isNone()); assertTrue(TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.all(BIGINT), B, Domain.none(BIGINT))).isNone()); }
@Test public void testBoolean() throws ParquetCorruptionException { String column = "BooleanColumn"; assertEquals(getDomain(BOOLEAN, 0, null, ID, column, true), all(BOOLEAN)); assertEquals(getDomain(BOOLEAN, 10, booleanColumnStats(true, true), ID, column, true), singleValue(BOOLEAN, true)); assertEquals(getDomain(BOOLEAN, 10, booleanColumnStats(false, false), ID, column, true), singleValue(BOOLEAN, false)); assertEquals(getDomain(BOOLEAN, 20, booleanColumnStats(false, true), ID, column, true), all(BOOLEAN)); }
@Test public void testNone() { assertTrue(TupleDomain.none().isNone()); assertEquals(TupleDomain.<ColumnHandle>none(), TupleDomain.withColumnDomains(ImmutableMap.of( A, Domain.none(BIGINT)))); assertEquals(TupleDomain.<ColumnHandle>none(), TupleDomain.withColumnDomains(ImmutableMap.of( A, Domain.all(BIGINT), B, Domain.none(VARCHAR)))); }
ImmutableMap.of(A, Domain.all(BIGINT)))); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of(A, Domain.all(BIGINT)))); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of(A, Domain.none(BIGINT)))); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of(A, Domain.singleValue(BIGINT, 0L)))); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of(B, Domain.all(VARCHAR)))); ImmutableMap.of( A, Domain.singleValue(BIGINT, 0L), B, Domain.all(DOUBLE)), ImmutableMap.of( A, Domain.singleValue(BIGINT, 0L), B, Domain.all(DOUBLE)))); B, Domain.all(VARCHAR)), ImmutableMap.of( A, Domain.singleValue(BIGINT, 0L), C, Domain.all(DOUBLE)))); B, Domain.all(VARCHAR)), ImmutableMap.of( A, Domain.singleValue(BIGINT, 1L),
@Test public void testMismatchedColumnWiseUnion() { TupleDomain<ColumnHandle> tupleDomain1 = TupleDomain.withColumnDomains( ImmutableMap.of( A, Domain.all(DOUBLE), B, Domain.singleValue(VARCHAR, utf8Slice("value")))); TupleDomain<ColumnHandle> tupleDomain2 = TupleDomain.withColumnDomains( ImmutableMap.of( A, Domain.create(ValueSet.ofRanges(Range.greaterThanOrEqual(DOUBLE, 0.0)), true), C, Domain.singleValue(BIGINT, 1L))); TupleDomain<ColumnHandle> expectedTupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(A, Domain.all(DOUBLE))); assertEquals(columnWiseUnion(tupleDomain1, tupleDomain2), expectedTupleDomain); }
@Test public void testContains() { assertTrue(Domain.all(BIGINT).contains(Domain.all(BIGINT))); assertTrue(Domain.all(BIGINT).contains(Domain.none(BIGINT))); assertTrue(Domain.all(BIGINT).contains(Domain.notNull(BIGINT))); assertTrue(Domain.all(BIGINT).contains(Domain.onlyNull(BIGINT))); assertTrue(Domain.all(BIGINT).contains(Domain.singleValue(BIGINT, 0L))); assertFalse(Domain.none(BIGINT).contains(Domain.all(BIGINT))); assertTrue(Domain.none(BIGINT).contains(Domain.none(BIGINT))); assertFalse(Domain.none(BIGINT).contains(Domain.notNull(BIGINT))); assertFalse(Domain.none(BIGINT).contains(Domain.onlyNull(BIGINT))); assertFalse(Domain.none(BIGINT).contains(Domain.singleValue(BIGINT, 0L))); assertFalse(Domain.notNull(BIGINT).contains(Domain.all(BIGINT))); assertTrue(Domain.notNull(BIGINT).contains(Domain.none(BIGINT))); assertTrue(Domain.notNull(BIGINT).contains(Domain.notNull(BIGINT))); assertFalse(Domain.notNull(BIGINT).contains(Domain.onlyNull(BIGINT))); assertTrue(Domain.notNull(BIGINT).contains(Domain.singleValue(BIGINT, 0L))); assertFalse(Domain.onlyNull(BIGINT).contains(Domain.all(BIGINT))); assertTrue(Domain.onlyNull(BIGINT).contains(Domain.none(BIGINT))); assertFalse(Domain.onlyNull(BIGINT).contains(Domain.notNull(BIGINT))); assertTrue(Domain.onlyNull(BIGINT).contains(Domain.onlyNull(BIGINT))); assertFalse(Domain.onlyNull(BIGINT).contains(Domain.singleValue(BIGINT, 0L))); assertFalse(Domain.singleValue(BIGINT, 0L).contains(Domain.all(BIGINT))); assertTrue(Domain.singleValue(BIGINT, 0L).contains(Domain.none(BIGINT))); assertFalse(Domain.singleValue(BIGINT, 0L).contains(Domain.notNull(BIGINT))); assertFalse(Domain.singleValue(BIGINT, 0L).contains(Domain.onlyNull(BIGINT))); assertTrue(Domain.singleValue(BIGINT, 0L).contains(Domain.singleValue(BIGINT, 0L))); }
@Test public void testToPredicateAllIgnored() { TupleDomain<Symbol> tupleDomain = withColumnDomains(ImmutableMap.<Symbol, Domain>builder() .put(C_BIGINT, Domain.singleValue(BIGINT, 1L)) .put(C_DOUBLE, Domain.onlyNull(DOUBLE)) .put(C_VARCHAR, Domain.notNull(VARCHAR)) .put(C_BOOLEAN, Domain.all(BOOLEAN)) .build()); ExtractionResult result = fromPredicate(toPredicate(tupleDomain)); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<Symbol, Domain>builder() .put(C_BIGINT, Domain.singleValue(BIGINT, 1L)) .put(C_DOUBLE, Domain.onlyNull(DOUBLE)) .put(C_VARCHAR, Domain.notNull(VARCHAR)) .build())); }
@Test public void testOverlaps() { assertTrue(Domain.all(BIGINT).overlaps(Domain.all(BIGINT))); assertFalse(Domain.all(BIGINT).overlaps(Domain.none(BIGINT))); assertTrue(Domain.all(BIGINT).overlaps(Domain.notNull(BIGINT))); assertTrue(Domain.all(BIGINT).overlaps(Domain.onlyNull(BIGINT))); assertTrue(Domain.all(BIGINT).overlaps(Domain.singleValue(BIGINT, 0L))); assertFalse(Domain.none(BIGINT).overlaps(Domain.all(BIGINT))); assertFalse(Domain.none(BIGINT).overlaps(Domain.none(BIGINT))); assertFalse(Domain.none(BIGINT).overlaps(Domain.notNull(BIGINT))); assertFalse(Domain.none(BIGINT).overlaps(Domain.onlyNull(BIGINT))); assertFalse(Domain.none(BIGINT).overlaps(Domain.singleValue(BIGINT, 0L))); assertTrue(Domain.notNull(BIGINT).overlaps(Domain.all(BIGINT))); assertFalse(Domain.notNull(BIGINT).overlaps(Domain.none(BIGINT))); assertTrue(Domain.notNull(BIGINT).overlaps(Domain.notNull(BIGINT))); assertFalse(Domain.notNull(BIGINT).overlaps(Domain.onlyNull(BIGINT))); assertTrue(Domain.notNull(BIGINT).overlaps(Domain.singleValue(BIGINT, 0L))); assertTrue(Domain.onlyNull(BIGINT).overlaps(Domain.all(BIGINT))); assertFalse(Domain.onlyNull(BIGINT).overlaps(Domain.none(BIGINT))); assertFalse(Domain.onlyNull(BIGINT).overlaps(Domain.notNull(BIGINT))); assertTrue(Domain.onlyNull(BIGINT).overlaps(Domain.onlyNull(BIGINT))); assertFalse(Domain.onlyNull(BIGINT).overlaps(Domain.singleValue(BIGINT, 0L))); assertTrue(Domain.singleValue(BIGINT, 0L).overlaps(Domain.all(BIGINT))); assertFalse(Domain.singleValue(BIGINT, 0L).overlaps(Domain.none(BIGINT))); assertTrue(Domain.singleValue(BIGINT, 0L).overlaps(Domain.notNull(BIGINT))); assertFalse(Domain.singleValue(BIGINT, 0L).overlaps(Domain.onlyNull(BIGINT))); assertTrue(Domain.singleValue(BIGINT, 0L).overlaps(Domain.singleValue(BIGINT, 0L))); }
@Test public void testEquatableNone() { Domain domain = Domain.none(ID); assertTrue(domain.isNone()); assertFalse(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.none(ID)); assertEquals(domain.getType(), ID); assertFalse(domain.includesNullableValue(0L)); assertFalse(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.all(ID)); }
ImmutableMap.of(A, Domain.all(BIGINT)))); ImmutableMap.of(A, Domain.all(BIGINT)))); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of())); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of(A, Domain.none(BIGINT)))); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of(A, Domain.all(BIGINT)))); ImmutableMap.of(A, Domain.all(BIGINT)), ImmutableMap.of(A, Domain.singleValue(BIGINT, 0L)))); ImmutableMap.of(A, Domain.all(BIGINT)))); A, Domain.all(BIGINT), B, Domain.singleValue(VARCHAR, utf8Slice("value"))), ImmutableMap.of( A, Domain.all(BIGINT), B, Domain.singleValue(VARCHAR, utf8Slice("value"))), ImmutableMap.of( A, Domain.all(BIGINT), B, Domain.singleValue(VARCHAR, utf8Slice("value"))), ImmutableMap.of(
@Test public void testExtractFixedValues() { assertEquals( TupleDomain.extractFixedValues(TupleDomain.withColumnDomains( ImmutableMap.<ColumnHandle, Domain>builder() .put(A, Domain.all(DOUBLE)) .put(B, Domain.singleValue(VARCHAR, utf8Slice("value"))) .put(C, Domain.onlyNull(BIGINT)) .put(D, Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L)), true)) .build())).get(), ImmutableMap.of( B, NullableValue.of(VARCHAR, utf8Slice("value")), C, NullableValue.asNull(BIGINT))); }
@Test public void testUnion() { assertUnion(Domain.all(BIGINT), Domain.all(BIGINT), Domain.all(BIGINT)); assertUnion(Domain.none(BIGINT), Domain.none(BIGINT), Domain.none(BIGINT)); assertUnion(Domain.all(BIGINT), Domain.none(BIGINT), Domain.all(BIGINT)); assertUnion(Domain.notNull(BIGINT), Domain.onlyNull(BIGINT), Domain.all(BIGINT)); assertUnion(Domain.singleValue(BIGINT, 0L), Domain.all(BIGINT), Domain.all(BIGINT)); assertUnion(Domain.singleValue(BIGINT, 0L), Domain.notNull(BIGINT), Domain.notNull(BIGINT)); assertUnion(Domain.singleValue(BIGINT, 0L), Domain.onlyNull(BIGINT), Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 0L)), true)); assertUnion(Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L)), true), Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 2L)), true), Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L), Range.equal(BIGINT, 2L)), true)); assertUnion(Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L)), true), Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L), Range.equal(BIGINT, 2L)), false), Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L), Range.equal(BIGINT, 2L)), true)); }
@Test public void testUncomparableNone() { Domain domain = Domain.none(HYPER_LOG_LOG); assertTrue(domain.isNone()); assertFalse(domain.isAll()); assertFalse(domain.isSingleValue()); assertFalse(domain.isNullableSingleValue()); assertFalse(domain.isNullAllowed()); assertEquals(domain.getValues(), ValueSet.none(HYPER_LOG_LOG)); assertEquals(domain.getType(), HYPER_LOG_LOG); assertFalse(domain.includesNullableValue(Slices.EMPTY_SLICE)); assertFalse(domain.includesNullableValue(null)); assertEquals(domain.complement(), Domain.all(HYPER_LOG_LOG)); }
@Test public void testLegacyCharComparedToVarcharExpression() testSimpleComparison(isDistinctFrom(cast(C_CHAR, VARCHAR), stringLiteral("123456789", VARCHAR)), C_CHAR, Domain.all(createCharType(10))); testSimpleComparison(isDistinctFrom(cast(C_CHAR, VARCHAR), stringLiteral("1234567890", VARCHAR)), C_CHAR, Domain.create(ValueSet.ofRanges( Range.lessThan(createCharType(10), Slices.utf8Slice("1234567890")), Range.greaterThan(createCharType(10), Slices.utf8Slice("1234567890"))), true)); testSimpleComparison(isDistinctFrom(cast(C_CHAR, VARCHAR), stringLiteral("12345678901", VARCHAR)), C_CHAR, Domain.all(createCharType(10)));
@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 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)); }