use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class MongoSession method buildQuery.
@VisibleForTesting
static Document buildQuery(TupleDomain<ColumnHandle> tupleDomain) {
Document query = new Document();
if (tupleDomain.getDomains().isPresent()) {
for (Map.Entry<ColumnHandle, Domain> entry : tupleDomain.getDomains().get().entrySet()) {
MongoColumnHandle column = (MongoColumnHandle) entry.getKey();
query.putAll(buildPredicate(column, entry.getValue()));
}
}
return query;
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class PinotPageSourceProvider method createPageSource.
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, ConnectorTableLayoutHandle tableLayoutHandle, List<ColumnHandle> columns, SplitContext splitContext) {
requireNonNull(split, "split is null");
PinotSplit pinotSplit = (PinotSplit) split;
checkArgument(pinotSplit.getConnectorId().equals(connectorId), "split is not for this connector");
List<PinotColumnHandle> handles = new ArrayList<>();
for (ColumnHandle handle : columns) {
handles.add((PinotColumnHandle) handle);
}
switch(pinotSplit.getSplitType()) {
case SEGMENT:
if (pinotConfig.isUseStreamingForSegmentQueries() && pinotSplit.getGrpcPort().orElse(-1) > 0) {
return new PinotSegmentStreamingPageSource(session, pinotConfig, pinotStreamingQueryClient, pinotSplit, handles);
}
return new PinotSegmentPageSource(session, pinotConfig, pinotQueryClient, pinotSplit, handles);
case BROKER:
switch(pinotSplit.getBrokerPinotQuery().get().getFormat()) {
case SQL:
return new PinotBrokerPageSourceSql(pinotConfig, session, pinotSplit.getBrokerPinotQuery().get(), handles, pinotSplit.getExpectedColumnHandles(), clusterInfoFetcher, objectMapper);
case PQL:
return new PinotBrokerPageSourcePql(pinotConfig, session, pinotSplit.getBrokerPinotQuery().get(), handles, pinotSplit.getExpectedColumnHandles(), clusterInfoFetcher, objectMapper);
}
default:
throw new UnsupportedOperationException("Unknown Pinot split type: " + pinotSplit.getSplitType());
}
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class PinotMetadata method getColumnHandles.
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) {
PinotTableHandle pinotTableHandle = (PinotTableHandle) tableHandle;
checkArgument(pinotTableHandle.getConnectorId().equals(connectorId), "tableHandle is not for this connector");
String pinotTableName = getPinotTableNameFromPrestoTableName(pinotTableHandle.getTableName());
PinotTable table = pinotPrestoConnection.getTable(pinotTableName);
if (table == null) {
throw new TableNotFoundException(pinotTableHandle.toSchemaTableName());
}
ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
for (ColumnMetadata column : table.getColumnsMetadata()) {
columnHandles.put(column.getName().toLowerCase(ENGLISH), new PinotColumnHandle(((PinotColumnMetadata) column).getPinotName(), column.getType(), REGULAR));
}
return columnHandles.build();
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestTpchMetadata method testOrdersOrderStatusPredicatePushdown.
@Test
public void testOrdersOrderStatusPredicatePushdown() {
TpchTableHandle tableHandle = tpchMetadata.getTableHandle(session, new SchemaTableName("sf1", ORDERS.getTableName()));
TupleDomain<ColumnHandle> domain;
ConnectorTableLayoutResult tableLayout;
domain = fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("P"));
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, ORDER_STATUS)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), TupleDomain.all(), session);
assertTupleDomainEquals(tableLayout.getTableLayout().getPredicate(), domain, session);
domain = fixedValueTupleDomain(tpchMetadata, ORDER_KEY, 42L);
tableLayout = getTableOnlyLayout(tpchMetadata, session, tableHandle, new Constraint<>(domain, convertToPredicate(domain, ORDER_STATUS)));
assertTupleDomainEquals(tableLayout.getUnenforcedConstraint(), domain, session);
assertTupleDomainEquals(tableLayout.getTableLayout().getPredicate(), // Using concrete expected value instead of checking TupleDomain::isNone to make sure the test doesn't pass on some other wrong value.
TupleDomain.columnWiseUnion(fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("F")), fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("O")), fixedValueTupleDomain(tpchMetadata, ORDER_STATUS, utf8Slice("P"))), session);
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestTpchMetadata method testColumnStats.
private void testColumnStats(String schema, TpchTable<?> table, TpchColumn<?> column, Constraint<ColumnHandle> constraint, ColumnStatistics expected) {
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);
ColumnHandle columnHandle = tpchMetadata.getColumnHandles(session, tableHandle).get(column.getSimplifiedColumnName());
ColumnStatistics actual = tableStatistics.getColumnStatistics().get(columnHandle);
EstimateAssertion estimateAssertion = new EstimateAssertion(TOLERANCE);
estimateAssertion.assertClose(actual.getDistinctValuesCount(), expected.getDistinctValuesCount(), "distinctValuesCount");
estimateAssertion.assertClose(actual.getDataSize(), expected.getDataSize(), "dataSize");
estimateAssertion.assertClose(actual.getNullsFraction(), expected.getNullsFraction(), "nullsFraction");
estimateAssertion.assertClose(actual.getRange(), expected.getRange(), "range");
}
Aggregations