use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class TestPruneIndexSourceColumns method buildProjectedIndexSource.
private static PlanNode buildProjectedIndexSource(PlanBuilder p, Predicate<Symbol> projectionFilter) {
Symbol orderkey = p.symbol("orderkey", INTEGER);
Symbol custkey = p.symbol("custkey", INTEGER);
Symbol totalprice = p.symbol("totalprice", DOUBLE);
ColumnHandle orderkeyHandle = new TpchColumnHandle(orderkey.getName(), INTEGER);
ColumnHandle custkeyHandle = new TpchColumnHandle(custkey.getName(), INTEGER);
ColumnHandle totalpriceHandle = new TpchColumnHandle(totalprice.getName(), DOUBLE);
return p.project(Assignments.copyOf(ImmutableList.of(orderkey, custkey, totalprice).stream().filter(projectionFilter).collect(Collectors.toMap(v -> v, v -> p.variable(v.getName())))), p.indexSource(new TableHandle(new CatalogName("local"), new TpchTableHandle("orders", TINY_SCALE_FACTOR), TpchTransactionHandle.INSTANCE, Optional.empty()), ImmutableSet.of(orderkey, custkey), ImmutableList.of(orderkey, custkey, totalprice), ImmutableMap.of(orderkey, orderkeyHandle, custkey, custkeyHandle, totalprice, totalpriceHandle), TupleDomain.fromFixedValues(ImmutableMap.of(totalpriceHandle, asNull(DOUBLE)))));
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class TestPushPredicateIntoTableScan method setUpBeforeClass.
@BeforeClass
public void setUpBeforeClass() {
pushPredicateIntoTableScan = new PushPredicateIntoTableScan(tester().getMetadata(), new TypeAnalyzer(new SqlParser(), tester().getMetadata()), true);
catalogName = tester().getCurrentConnectorId();
TpchTableHandle nation = new TpchTableHandle("nation", 1.0);
nationTableHandle = new TableHandle(catalogName, nation, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(nation, TupleDomain.all())));
TpchTableHandle orders = new TpchTableHandle("orders", 1.0);
ordersTableHandle = new TableHandle(catalogName, orders, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(orders, TupleDomain.all())));
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class TestStarTreeAggregationRule method testDoNotFireWhenWithoutCube.
@Test
public void testDoNotFireWhenWithoutCube() {
Mockito.when(cubeManager.getCubeProvider(anyString())).then(new Returns(Optional.of(provider)));
Mockito.when(cubeManager.getMetaStore(anyString())).then(new Returns(Optional.of(cubeMetaStore)));
TpchTableHandle orders = new TpchTableHandle("orders", 1.0);
TableHandle tmpOrdersTableHandle = new TableHandle(tester().getCurrentConnectorId(), orders, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(orders, TupleDomain.all())));
Mockito.when(cubeMetaStore.getMetadataList(eq("local.sf1.0.orders"))).then(new Returns(ImmutableList.of()));
StarTreeAggregationRule starTreeAggregationRule = new StarTreeAggregationRule(cubeManager, tester().getMetadata());
tester().assertThat(starTreeAggregationRule).setSystemProperty(ENABLE_STAR_TREE_INDEX, "true").on(p -> p.aggregation(builder -> builder.globalGrouping().addAggregation(p.symbol("count", BIGINT), new FunctionCallBuilder(tester().getMetadata()).setName(QualifiedName.of("count")).build(), ImmutableList.of(BIGINT)).step(SINGLE).source(p.project(Assignments.builder().put(p.symbol("custkey"), OriginalExpressionUtils.castToRowExpression(SymbolUtils.toSymbolReference(p.symbol("custkey")))).build(), p.tableScan(tmpOrdersTableHandle, ImmutableList.of(p.symbol("orderkey", BIGINT)), ImmutableMap.of(p.symbol("orderkey", BIGINT), new TpchColumnHandle("orderkey", BIGINT))))))).doesNotFire();
Mockito.verify(cubeMetaStore, Mockito.atLeastOnce()).getMetadataList(eq("local.sf1.0.orders"));
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class TestStarTreeAggregationRule method testDoNotFireWhenFeatureIsDisabled.
@Test
public void testDoNotFireWhenFeatureIsDisabled() {
Mockito.when(cubeManager.getCubeProvider(anyString())).then(new Returns(Optional.of(provider)));
Mockito.when(cubeManager.getMetaStore(anyString())).then(new Returns(Optional.of(cubeMetaStore)));
TpchTableHandle orders = new TpchTableHandle("orders", 1.0);
TableHandle tmpOrdersTableHandle = new TableHandle(tester().getCurrentConnectorId(), orders, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(orders, TupleDomain.all())));
StarTreeAggregationRule starTreeAggregationRule = new StarTreeAggregationRule(cubeManager, tester().getMetadata());
tester().assertThat(starTreeAggregationRule).setSystemProperty(ENABLE_STAR_TREE_INDEX, "false").on(p -> p.aggregation(builder -> builder.globalGrouping().addAggregation(p.symbol("count", BIGINT), new FunctionCallBuilder(tester().getMetadata()).setName(QualifiedName.of("count")).build(), ImmutableList.of(BIGINT)).step(SINGLE).source(p.project(Assignments.builder().put(p.symbol("custkey"), p.variable("custkey", custkeyHandle.getType())).build(), p.tableScan(tmpOrdersTableHandle, ImmutableList.of(p.symbol("orderkey", BIGINT)), ImmutableMap.of(p.symbol("orderkey", BIGINT), new TpchColumnHandle("orderkey", BIGINT))))))).doesNotFire();
Mockito.verify(cubeMetaStore, Mockito.never()).getMetadataList(eq("local.sf1.0.orders"));
}
use of io.prestosql.spi.metadata.TableHandle in project hetu-core by openlookeng.
the class TableDeleteOperator method getOutput.
@Override
public Page getOutput() {
if (state == State.FINISHED || (sourceLayout.isPresent() && state != State.FINISHING)) {
return null;
}
state = State.FINISHED;
TableHandle tableHandleForDelete = tableHandle;
if (sourceLayout.isPresent()) {
// Replace the values from subqueries in filter predicates
VariablesExtractor.extractUnique(filter.get()).stream().forEach(expr -> symbolExpressionMap.putIfAbsent(new Symbol(expr.getName()), expr));
RowExpression rowExpression = RowExpressionVariableInliner.inlineVariables(node -> symbolExpressionMap.get(new Symbol(node.getName())), filter.get());
// Create the tuple domain based on filter and values from source;
RowExpressionDomainTranslator.ExtractionResult<VariableReferenceExpression> decomposedPredicate = (new RowExpressionDomainTranslator(metadata)).fromPredicate(session.toConnectorSession(), rowExpression, RowExpressionDomainTranslator.BASIC_COLUMN_EXTRACTOR);
TupleDomain<ColumnHandle> tupleDomain = decomposedPredicate.getTupleDomain().transform(variableName -> assignments.get(new Symbol(variableName.getName())));
Constraint constraint = new Constraint(tupleDomain);
// Apply the constraint on the table handle
Optional<TableHandle> tableHandleDelete = metadata.applyDelete(session, this.tableHandle, constraint);
if (tableHandleDelete.isPresent()) {
tableHandleForDelete = tableHandleDelete.get();
}
}
OptionalLong rowsDeletedCount = metadata.executeDelete(session, tableHandleForDelete);
// output page will only be constructed once,
// so a new PageBuilder is constructed (instead of using PageBuilder.reset)
PageBuilder page = new PageBuilder(1, TYPES);
BlockBuilder rowsBuilder = page.getBlockBuilder(0);
page.declarePosition();
if (rowsDeletedCount.isPresent()) {
BIGINT.writeLong(rowsBuilder, rowsDeletedCount.getAsLong());
} else {
rowsBuilder.appendNull();
}
return page.build();
}
Aggregations