use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestTpchMetadata method testTableStats.
private void testTableStats(String schema, TpchTable<?> table, Constraint<ColumnHandle> constraint, double expectedRowCount) {
TpchTableHandle tableHandle = tpchMetadata.getTableHandle(session, new SchemaTableName(schema, table.getTableName()));
List<ColumnHandle> columnHandles = ImmutableList.copyOf(tpchMetadata.getColumnHandles(session, tableHandle).values());
TableStatistics tableStatistics = tpchMetadata.getTableStatistics(session, tableHandle, Optional.empty(), columnHandles, constraint);
double actualRowCountValue = tableStatistics.getRowCount().getValue();
assertEquals(tableStatistics.getRowCount(), Estimate.of(actualRowCountValue));
assertEquals(actualRowCountValue, expectedRowCount, expectedRowCount * TOLERANCE);
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestTpchMetadata method testPartTypeAndPartContainerPredicatePushdown.
@Test
public void testPartTypeAndPartContainerPredicatePushdown() {
TpchTableHandle tableHandle = tpchMetadata.getTableHandle(session, new SchemaTableName("sf1", PART.getTableName()));
TupleDomain<ColumnHandle> domain;
ConnectorTableLayoutResult tableLayout;
domain = fixedValueTupleDomain(tpchMetadata, PartColumn.TYPE, utf8Slice("SMALL BRUSHED COPPER"));
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, PartColumn.TYPE)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), TupleDomain.all(), session);
assertTupleDomainEquals(filterOutColumnFromPredicate(tableLayout.getTableLayout().getPredicate(), tpchMetadata.toColumnHandle(PartColumn.CONTAINER)), domain, session);
domain = fixedValueTupleDomain(tpchMetadata, PartColumn.TYPE, utf8Slice("UNKNOWN"));
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, PartColumn.TYPE)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), TupleDomain.all(), session);
assertTupleDomainEquals(tableLayout.getTableLayout().getPredicate(), TupleDomain.none(), session);
domain = fixedValueTupleDomain(tpchMetadata, PartColumn.CONTAINER, utf8Slice("SM BAG"));
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, PartColumn.CONTAINER)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), TupleDomain.all(), session);
assertTupleDomainEquals(filterOutColumnFromPredicate(tableLayout.getTableLayout().getPredicate(), tpchMetadata.toColumnHandle(PartColumn.TYPE)), domain, session);
domain = fixedValueTupleDomain(tpchMetadata, PartColumn.CONTAINER, utf8Slice("UNKNOWN"));
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, PartColumn.CONTAINER)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), TupleDomain.all(), session);
assertTupleDomainEquals(tableLayout.getTableLayout().getPredicate(), TupleDomain.none(), session);
domain = fixedValueTupleDomain(tpchMetadata, PartColumn.TYPE, utf8Slice("SMALL BRUSHED COPPER"), PartColumn.CONTAINER, utf8Slice("SM BAG"));
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, PartColumn.CONTAINER)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), TupleDomain.all(), session);
assertTupleDomainEquals(tableLayout.getTableLayout().getPredicate(), domain, session);
domain = fixedValueTupleDomain(tpchMetadata, PartColumn.TYPE, utf8Slice("UNKNOWN"), PartColumn.CONTAINER, utf8Slice("UNKNOWN"));
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, PartColumn.TYPE, PartColumn.CONTAINER)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), TupleDomain.all(), session);
assertTupleDomainEquals(tableLayout.getTableLayout().getPredicate(), TupleDomain.none(), session);
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestMongoSession method testBuildQueryStringType.
@Test
public void testBuildQueryStringType() {
TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(COL1, Domain.create(ValueSet.ofRanges(range(createUnboundedVarcharType(), utf8Slice("hello"), false, utf8Slice("world"), true)), false), COL2, Domain.create(ValueSet.ofRanges(greaterThanOrEqual(createUnboundedVarcharType(), utf8Slice("a value"))), false)));
Document query = MongoSession.buildQuery(tupleDomain);
Document expected = new Document().append(COL1.getName(), new Document().append("$gt", "hello").append("$lte", "world")).append(COL2.getName(), new Document("$gte", "a value"));
assertEquals(query, expected);
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestMongoSession method testBuildQueryNull.
@Test
public void testBuildQueryNull() {
TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(COL1, Domain.create(ValueSet.ofRanges(greaterThan(BIGINT, 200L)), true)));
Document query = MongoSession.buildQuery(tupleDomain);
Document expected = new Document("$or", asList(new Document(COL1.getName(), new Document("$gt", 200L)), new Document(COL1.getName(), new Document("$exists", true).append("$eq", null))));
assertEquals(query, expected);
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestMongoSession method testBuildQuery.
@Test
public void testBuildQuery() {
TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(COL1, Domain.create(ValueSet.ofRanges(range(BIGINT, 100L, false, 200L, true)), false), COL2, Domain.singleValue(createUnboundedVarcharType(), utf8Slice("a value"))));
Document query = MongoSession.buildQuery(tupleDomain);
Document expected = new Document().append(COL1.getName(), new Document().append("$gt", 100L).append("$lte", 200L)).append(COL2.getName(), new Document("$eq", "a value"));
assertEquals(query, expected);
}
Aggregations