use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestRemoveUnsupportedDynamicFilters method setup.
@BeforeClass
public void setup() {
metadata = getQueryRunner().getMetadata();
logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(metadata.getFunctionAndTypeManager()), new FunctionResolution(metadata.getFunctionAndTypeManager()), metadata.getFunctionAndTypeManager());
builder = new PlanBuilder(getQueryRunner().getDefaultSession(), new PlanNodeIdAllocator(), metadata);
ConnectorId connectorId = getCurrentConnectorId();
TableHandle lineitemTableHandle = new TableHandle(connectorId, new TpchTableHandle("lineitem", 1.0), TestingTransactionHandle.create(), Optional.empty());
lineitemOrderKeyVariable = builder.variable("LINEITEM_OK", BIGINT);
lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeyVariable), ImmutableMap.of(lineitemOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
TableHandle ordersTableHandle = new TableHandle(connectorId, new TpchTableHandle("orders", 1.0), TestingTransactionHandle.create(), Optional.empty());
ordersOrderKeyVariable = builder.variable("ORDERS_OK", BIGINT);
ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeyVariable), ImmutableMap.of(ordersOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestDynamicFiltersChecker method setup.
@BeforeClass
public void setup() {
metadata = getQueryRunner().getMetadata();
logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(metadata.getFunctionAndTypeManager()), new FunctionResolution(metadata.getFunctionAndTypeManager()), metadata.getFunctionAndTypeManager());
builder = new PlanBuilder(getQueryRunner().getDefaultSession(), new PlanNodeIdAllocator(), metadata);
ConnectorId connectorId = getCurrentConnectorId();
TableHandle lineitemTableHandle = new TableHandle(connectorId, new TpchTableHandle("lineitem", 1.0), TestingTransactionHandle.create(), Optional.empty());
lineitemOrderKeyVariable = builder.variable("LINEITEM_OK", BIGINT);
lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeyVariable), ImmutableMap.of(lineitemOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
TableHandle ordersTableHandle = new TableHandle(connectorId, new TpchTableHandle("orders", 1.0), TestingTransactionHandle.create(), Optional.empty());
ordersOrderKeyVariable = builder.variable("ORDERS_OK", BIGINT);
ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeyVariable), ImmutableMap.of(ordersOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestValidateAggregationsWithDefaultValues method setup.
@BeforeClass
public void setup() {
metadata = getQueryRunner().getMetadata();
builder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), metadata);
ConnectorId connectorId = getCurrentConnectorId();
TpchTableHandle nationTpchTableHandle = new TpchTableHandle("nation", 1.0);
TableHandle nationTableHandle = new TableHandle(connectorId, nationTpchTableHandle, TestingTransactionHandle.create(), Optional.of(new TpchTableLayoutHandle(nationTpchTableHandle, TupleDomain.all())));
TpchColumnHandle nationkeyColumnHandle = new TpchColumnHandle("nationkey", BIGINT);
variable = builder.variable("nationkey");
tableScanNode = builder.tableScan(nationTableHandle, ImmutableList.of(variable), ImmutableMap.of(variable, nationkeyColumnHandle));
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TpchIndexProvider method getIndex.
@Override
public ConnectorIndex getIndex(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorIndexHandle indexHandle, List<ColumnHandle> lookupSchema, List<ColumnHandle> outputSchema) {
TpchIndexHandle tpchIndexHandle = (TpchIndexHandle) indexHandle;
Map<ColumnHandle, NullableValue> fixedValues = TupleDomain.extractFixedValues(tpchIndexHandle.getFixedValues()).get();
checkArgument(lookupSchema.stream().noneMatch(handle -> fixedValues.keySet().contains(handle)), "Lookup columnHandles are not expected to overlap with the fixed value predicates");
// Establish an order for the fixedValues
List<ColumnHandle> fixedValueColumns = ImmutableList.copyOf(fixedValues.keySet());
// Extract the fixedValues as their raw values and types
List<Object> rawFixedValues = new ArrayList<>(fixedValueColumns.size());
List<Type> rawFixedTypes = new ArrayList<>(fixedValueColumns.size());
for (ColumnHandle fixedValueColumn : fixedValueColumns) {
rawFixedValues.add(fixedValues.get(fixedValueColumn).getValue());
rawFixedTypes.add(((TpchColumnHandle) fixedValueColumn).getType());
}
// Establish the schema after we append the fixed values to the lookup keys.
List<ColumnHandle> finalLookupSchema = ImmutableList.<ColumnHandle>builder().addAll(lookupSchema).addAll(fixedValueColumns).build();
Optional<TpchIndexedData.IndexedTable> indexedTable = indexedData.getIndexedTable(tpchIndexHandle.getTableName(), tpchIndexHandle.getScaleFactor(), tpchIndexHandle.getIndexColumnNames());
checkState(indexedTable.isPresent());
TpchIndexedData.IndexedTable table = indexedTable.get();
// Compute how to map from the final lookup schema to the table index key order
List<Integer> keyRemap = computeRemap(handleToNames(finalLookupSchema), table.getKeyColumns());
Function<RecordSet, RecordSet> keyFormatter = key -> new MappedRecordSet(new AppendingRecordSet(key, rawFixedValues, rawFixedTypes), keyRemap);
// Compute how to map from the output of the indexed data to the expected output schema
List<Integer> outputRemap = computeRemap(table.getOutputColumns(), handleToNames(outputSchema));
Function<RecordSet, RecordSet> outputFormatter = output -> new MappedRecordSet(output, outputRemap);
return new TpchConnectorIndex(keyFormatter, outputFormatter, table);
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestPickTableLayout method ruleWithPushdownableToTableLayoutPredicate.
@Test
public void ruleWithPushdownableToTableLayoutPredicate() {
Type orderStatusType = createVarcharType(1);
tester().assertThat(pickTableLayout.pickTableLayoutForPredicate()).on(p -> {
p.variable("orderstatus", createVarcharType(1));
return p.filter(p.rowExpression("orderstatus = 'O'"), p.tableScan(ordersTableHandle, ImmutableList.of(p.variable("orderstatus", orderStatusType)), ImmutableMap.of(p.variable("orderstatus", orderStatusType), new TpchColumnHandle("orderstatus", orderStatusType))));
}).matches(constrainedTableScanWithTableLayout("orders", ImmutableMap.of("orderstatus", singleValue(orderStatusType, utf8Slice("O"))), ImmutableMap.of("orderstatus", "orderstatus")));
tester().assertThat(pickTableLayout.pickTableLayoutForPredicate()).on(p -> {
p.variable("orderstatus", orderStatusType);
return p.filter(p.rowExpression("orderstatus = 'O'"), p.tableScan(ordersTableHandle, ImmutableList.of(variable("orderstatus", orderStatusType)), ImmutableMap.of(variable("orderstatus", orderStatusType), new TpchColumnHandle("orderstatus", orderStatusType))));
}).matches(constrainedTableScanWithTableLayout("orders", ImmutableMap.of("orderstatus", singleValue(orderStatusType, utf8Slice("O"))), ImmutableMap.of("orderstatus", "orderstatus")));
}
Aggregations