Search in sources :

Example 6 with TpchTableHandle

use of io.prestosql.plugin.tpch.TpchTableHandle in project hetu-core by openlookeng.

the class H2QueryRunner method insertRows.

private void insertRows(TpchMetadata tpchMetadata, TpchTable<?> tpchTable) {
    TpchTableHandle tableHandle = tpchMetadata.getTableHandle(null, new SchemaTableName(TINY_SCHEMA_NAME, tpchTable.getTableName()));
    insertRows(tpchMetadata.getTableMetadata(null, tableHandle), handle, createTpchRecordSet(tpchTable, tableHandle.getScaleFactor()));
}
Also used : SchemaTableName(io.prestosql.spi.connector.SchemaTableName) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle)

Example 7 with TpchTableHandle

use of io.prestosql.plugin.tpch.TpchTableHandle in project hetu-core by openlookeng.

the class TpchIndexMetadata method resolveIndex.

@Override
public Optional<ConnectorResolvedIndex> resolveIndex(ConnectorSession session, ConnectorTableHandle tableHandle, Set<ColumnHandle> indexableColumns, Set<ColumnHandle> outputColumns, TupleDomain<ColumnHandle> tupleDomain) {
    TpchTableHandle tpchTableHandle = (TpchTableHandle) tableHandle;
    // Keep the fixed values that don't overlap with the indexableColumns
    // Note: technically we could more efficiently utilize the overlapped columns, but this way is simpler for now
    Map<ColumnHandle, NullableValue> fixedValues = TupleDomain.extractFixedValues(tupleDomain).orElse(ImmutableMap.of()).entrySet().stream().filter(entry -> !indexableColumns.contains(entry.getKey())).filter(// strip nulls since meaningless in index join lookups
    entry -> !entry.getValue().isNull()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    // determine all columns available for index lookup
    Set<String> lookupColumnNames = ImmutableSet.<String>builder().addAll(handleToNames(ImmutableList.copyOf(indexableColumns))).addAll(handleToNames(ImmutableList.copyOf(fixedValues.keySet()))).build();
    // do we have an index?
    if (!indexedData.getIndexedTable(tpchTableHandle.getTableName(), tpchTableHandle.getScaleFactor(), lookupColumnNames).isPresent()) {
        return Optional.empty();
    }
    TupleDomain<ColumnHandle> filteredTupleDomain = tupleDomain;
    if (!tupleDomain.isNone()) {
        filteredTupleDomain = TupleDomain.withColumnDomains(Maps.filterKeys(tupleDomain.getDomains().get(), not(in(fixedValues.keySet()))));
    }
    TpchIndexHandle indexHandle = new TpchIndexHandle(tpchTableHandle.getTableName(), tpchTableHandle.getScaleFactor(), lookupColumnNames, TupleDomain.fromFixedValues(fixedValues));
    return Optional.of(new ConnectorResolvedIndex(indexHandle, filteredTupleDomain));
}
Also used : TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle) TupleDomain(io.prestosql.spi.predicate.TupleDomain) Set(java.util.Set) ConnectorResolvedIndex(io.prestosql.spi.connector.ConnectorResolvedIndex) NullableValue(io.prestosql.spi.predicate.NullableValue) TpchIndexProvider.handleToNames(io.prestosql.tests.tpch.TpchIndexProvider.handleToNames) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Predicates.in(com.google.common.base.Predicates.in) ImmutableList(com.google.common.collect.ImmutableList) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) Predicates.not(com.google.common.base.Predicates.not) TpchMetadata(io.prestosql.plugin.tpch.TpchMetadata) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Optional(java.util.Optional) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) ConnectorResolvedIndex(io.prestosql.spi.connector.ConnectorResolvedIndex) NullableValue(io.prestosql.spi.predicate.NullableValue) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle)

Example 8 with TpchTableHandle

use of io.prestosql.plugin.tpch.TpchTableHandle in project hetu-core by openlookeng.

the class TestCubeStatementGenerator method setup.

@BeforeClass
public void setup() {
    planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata());
    symbolAllocator = new PlanSymbolAllocator();
    builder = CubeStatement.newBuilder();
    columnOrderkey = symbolAllocator.newSymbol("orderkey", BIGINT);
    columnTotalprice = symbolAllocator.newSymbol("totalprice", DOUBLE);
    columnAvgPrice = symbolAllocator.newSymbol("avgprice", DOUBLE);
    orderkeyHandle = new TpchColumnHandle("orderkey", BIGINT);
    totalpriceHandle = new TpchColumnHandle("totalprice", DOUBLE);
    columnMapping = new HashMap<>();
    columnMapping.put("orderkey", orderkeyHandle);
    columnMapping.put("totalprice", totalpriceHandle);
    columnMapping.put("avgprice", columnAvgPrice);
    Map<Symbol, ColumnHandle> assignments = ImmutableMap.<Symbol, ColumnHandle>builder().put(columnOrderkey, orderkeyHandle).put(columnTotalprice, totalpriceHandle).build();
    TpchTableHandle orders = new TpchTableHandle("orders", 1.0);
    TableHandle ordersTableHandle = new TableHandle(new CatalogName("test"), orders, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(orders, TupleDomain.all())));
    baseTableScan = new TableScanNode(new PlanNodeId(UUID.randomUUID().toString()), ordersTableHandle, ImmutableList.copyOf(assignments.keySet()), assignments, Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
}
Also used : TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TableScanNode(io.prestosql.spi.plan.TableScanNode) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) CatalogName(io.prestosql.spi.connector.CatalogName) UUID(java.util.UUID) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with TpchTableHandle

use of io.prestosql.plugin.tpch.TpchTableHandle in project hetu-core by openlookeng.

the class TestCostCalculator method tableScan.

private TableScanNode tableScan(String id, String... symbols) {
    List<Symbol> symbolsList = Arrays.stream(symbols).map(Symbol::new).collect(toImmutableList());
    ImmutableMap.Builder<Symbol, ColumnHandle> assignments = ImmutableMap.builder();
    for (Symbol symbol : symbolsList) {
        assignments.put(symbol, new TpchColumnHandle("orderkey", BIGINT));
    }
    TpchTableHandle tableHandle = new TpchTableHandle("orders", 1.0);
    return new TableScanNode(new PlanNodeId(id), new TableHandle(new CatalogName("tpch"), tableHandle, INSTANCE, Optional.of(new TpchTableLayoutHandle(tableHandle, TupleDomain.all()))), symbolsList, assignments.build(), TupleDomain.all(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
}
Also used : TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) ImmutableMap(com.google.common.collect.ImmutableMap) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TableScanNode(io.prestosql.spi.plan.TableScanNode) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) CatalogName(io.prestosql.spi.connector.CatalogName) UUID(java.util.UUID) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle)

Example 10 with TpchTableHandle

use of io.prestosql.plugin.tpch.TpchTableHandle in project hetu-core by openlookeng.

the class TestStarTreeAggregationRule method setupBeforeClass.

@BeforeClass
public void setupBeforeClass() {
    PlanSymbolAllocator symbolAllocator = new PlanSymbolAllocator();
    columnOrderkey = symbolAllocator.newSymbol("orderkey", BIGINT);
    columnOrderDate = symbolAllocator.newSymbol("orderdate", DATE);
    columnCustkey = symbolAllocator.newSymbol("custkey", BIGINT);
    columnTotalprice = symbolAllocator.newSymbol("totalprice", DOUBLE);
    orderkeyHandle = new TpchColumnHandle("orderkey", BIGINT);
    orderdateHandle = new TpchColumnHandle("orderdate", DATE);
    custkeyHandle = new TpchColumnHandle("custkey", BIGINT);
    totalpriceHandle = new TpchColumnHandle("totalprice", DOUBLE);
    ColumnMetadata orderKeyColumnMetadata = new ColumnMetadata(orderkeyHandle.getColumnName(), orderkeyHandle.getType());
    ColumnMetadata orderDateColumnMetadata = new ColumnMetadata(orderdateHandle.getColumnName(), orderdateHandle.getType());
    ColumnMetadata custKeyColumnMetadata = new ColumnMetadata(custkeyHandle.getColumnName(), custkeyHandle.getType());
    ColumnMetadata totalPriceColumnMetadata = new ColumnMetadata(totalpriceHandle.getColumnName(), totalpriceHandle.getType());
    output = symbolAllocator.newSymbol("output", DOUBLE);
    assignments = ImmutableMap.<Symbol, ColumnHandle>builder().put(columnOrderkey, orderkeyHandle).put(columnOrderDate, orderdateHandle).put(columnCustkey, custkeyHandle).put(columnTotalprice, totalpriceHandle).build();
    TpchTableHandle orders = new TpchTableHandle("orders", 1.0);
    ordersTableHandle = new TableHandle(tester().getCurrentConnectorId(), orders, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(orders, TupleDomain.all())));
    baseTableScan = new TableScanNode(newId(), ordersTableHandle, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
    QualifiedObjectName baseTableName = QualifiedObjectName.valueOf(baseTableScan.getTable().getFullyQualifiedName());
    baseTableMetadata = new TableMetadata(ordersTableHandle.getCatalogName(), new ConnectorTableMetadata(new SchemaTableName(baseTableName.getSchemaName(), baseTableName.getObjectName()), Arrays.asList(orderKeyColumnMetadata, orderDateColumnMetadata, custKeyColumnMetadata, totalPriceColumnMetadata)));
    columnCountAll = symbolAllocator.newSymbol("count_all", BIGINT);
    columnSumTotalPrice = symbolAllocator.newSymbol("sum_totalprice", DOUBLE);
    columnCountOrderKey = symbolAllocator.newSymbol("count_orderkey", BIGINT);
    columnGroupingBitSet = symbolAllocator.newSymbol("grouping_bit_set", BIGINT);
    cubeColumnCustKey = symbolAllocator.newSymbol("custkey", BIGINT);
    cubeColumnOrderDate = symbolAllocator.newSymbol("orderdate", DATE);
    countAllHandle = new TpchColumnHandle("count_all", BIGINT);
    sumTotalPriceHandle = new TpchColumnHandle("sum_totalprice", DOUBLE);
    countOrderKeyHandle = new TpchColumnHandle("count_orderkey", BIGINT);
    groupingBitSetHandle = new TpchColumnHandle("grouping_bit_set", BIGINT);
    custKeyCubeColumnHandle = new TpchColumnHandle("custkey", BIGINT);
    orderDateCubeColumnHandle = new TpchColumnHandle("orderdate", DATE);
    ordersCubeColumnHandles.put(countAllHandle.getColumnName(), countAllHandle);
    ordersCubeColumnHandles.put(sumTotalPriceHandle.getColumnName(), sumTotalPriceHandle);
    ordersCubeColumnHandles.put(countOrderKeyHandle.getColumnName(), countOrderKeyHandle);
    ordersCubeColumnHandles.put(groupingBitSetHandle.getColumnName(), groupingBitSetHandle);
    ordersCubeColumnHandles.put(custKeyCubeColumnHandle.getColumnName(), custKeyCubeColumnHandle);
    ordersCubeColumnHandles.put(orderDateCubeColumnHandle.getColumnName(), orderDateCubeColumnHandle);
    TpchTableHandle ordersCube = new TpchTableHandle("orders_cube", 1.0);
    ordersCubeHandle = new TableHandle(tester().getCurrentConnectorId(), ordersCube, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(ordersCube, TupleDomain.all())));
    countAllColumnMetadata = new ColumnMetadata(countAllHandle.getColumnName(), countAllHandle.getType());
    sumTotalPriceColumnMetadata = new ColumnMetadata(sumTotalPriceHandle.getColumnName(), sumTotalPriceHandle.getType());
    countOrderKeyColumnMetadata = new ColumnMetadata(countOrderKeyHandle.getColumnName(), countOrderKeyHandle.getType());
    groupingBitSetColumnMetadata = new ColumnMetadata(groupingBitSetHandle.getColumnName(), groupingBitSetHandle.getType());
    custKeyCubeColumnMetadata = new ColumnMetadata(custKeyCubeColumnHandle.getColumnName(), custKeyCubeColumnHandle.getType());
    orderDateCubeColumnMetadata = new ColumnMetadata(orderDateCubeColumnHandle.getColumnName(), orderDateCubeColumnHandle.getType());
    config = new FeaturesConfig();
    config.setEnableStarTreeIndex(true);
    cubeManager = Mockito.mock(CubeManager.class);
    provider = Mockito.mock(CubeProvider.class);
    cubeMetaStore = Mockito.mock(CubeMetaStore.class);
    cubeMetadata = Mockito.mock(CubeMetadata.class);
    ordersTableHandleMatcher = new BaseMatcher<TableHandle>() {

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof TableHandle)) {
                return false;
            }
            TableHandle th = (TableHandle) o;
            return th.getFullyQualifiedName().equals(ordersTableHandle.getFullyQualifiedName());
        }

        @Override
        public void describeTo(Description description) {
        }
    };
    ordersCubeHandleMatcher = new BaseMatcher<TableHandle>() {

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof TableHandle)) {
                return false;
            }
            TableHandle th = (TableHandle) o;
            return th.getFullyQualifiedName().equals(ordersCubeHandle.getFullyQualifiedName());
        }

        @Override
        public void describeTo(Description description) {
        }
    };
    countAllColumnHandleMatcher = new BaseMatcher<ColumnHandle>() {

        @Override
        public void describeTo(Description description) {
        }

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof ColumnHandle)) {
                return false;
            }
            ColumnHandle ch = (ColumnHandle) o;
            return ch.getColumnName().equalsIgnoreCase(countAllHandle.getColumnName());
        }
    };
    sumTotalPriceColumnHandleMatcher = new BaseMatcher<ColumnHandle>() {

        @Override
        public void describeTo(Description description) {
        }

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof ColumnHandle)) {
                return false;
            }
            ColumnHandle ch = (ColumnHandle) o;
            return ch.getColumnName().equalsIgnoreCase(sumTotalPriceHandle.getColumnName());
        }
    };
    countOrderKeyColumnHandleMatcher = new BaseMatcher<ColumnHandle>() {

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof ColumnHandle)) {
                return false;
            }
            ColumnHandle ch = (ColumnHandle) o;
            return ch.getColumnName().equalsIgnoreCase(countOrderKeyHandle.getColumnName());
        }

        @Override
        public void describeTo(Description description) {
        }
    };
    groupingBitSetColumnHandleMatcher = new BaseMatcher<ColumnHandle>() {

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof ColumnHandle)) {
                return false;
            }
            ColumnHandle ch = (ColumnHandle) o;
            return ch.getColumnName().equalsIgnoreCase(groupingBitSetHandle.getColumnName());
        }

        @Override
        public void describeTo(Description description) {
        }
    };
    orderDateCubeColumnHandleMatcher = new BaseMatcher<ColumnHandle>() {

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof ColumnHandle)) {
                return false;
            }
            ColumnHandle ch = (ColumnHandle) o;
            return ch.getColumnName().equalsIgnoreCase(orderDateCubeColumnHandle.getColumnName());
        }

        @Override
        public void describeTo(Description description) {
        }
    };
    custKeyCubeColumnHandleMatcher = new BaseMatcher<ColumnHandle>() {

        @Override
        public boolean matches(Object o) {
            if (!(o instanceof ColumnHandle)) {
                return false;
            }
            ColumnHandle ch = (ColumnHandle) o;
            return ch.getColumnName().equalsIgnoreCase(custKeyCubeColumnHandle.getColumnName());
        }

        @Override
        public void describeTo(Description description) {
        }
    };
}
Also used : TableMetadata(io.prestosql.metadata.TableMetadata) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) Description(org.hamcrest.Description) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) CubeMetaStore(io.hetu.core.spi.cube.io.CubeMetaStore) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) CubeManager(io.prestosql.cube.CubeManager) TableScanNode(io.prestosql.spi.plan.TableScanNode) CubeProvider(io.prestosql.spi.cube.CubeProvider) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) UUID(java.util.UUID) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TpchTableHandle (io.prestosql.plugin.tpch.TpchTableHandle)13 TableHandle (io.prestosql.spi.metadata.TableHandle)10 TpchColumnHandle (io.prestosql.plugin.tpch.TpchColumnHandle)9 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)9 Symbol (io.prestosql.spi.plan.Symbol)9 BeforeClass (org.testng.annotations.BeforeClass)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 TpchTableLayoutHandle (io.prestosql.plugin.tpch.TpchTableLayoutHandle)7 TableScanNode (io.prestosql.spi.plan.TableScanNode)7 ImmutableList (com.google.common.collect.ImmutableList)6 PlanBuilder (io.prestosql.sql.planner.iterative.rule.test.PlanBuilder)6 UUID (java.util.UUID)6 CatalogName (io.prestosql.spi.connector.CatalogName)5 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)5 PlanNodeIdAllocator (io.prestosql.spi.plan.PlanNodeIdAllocator)5 TupleDomain (io.prestosql.spi.predicate.TupleDomain)5 PlanSymbolAllocator (io.prestosql.sql.planner.PlanSymbolAllocator)5 Optional (java.util.Optional)5 CubeMetadata (io.hetu.core.spi.cube.CubeMetadata)4 Session (io.prestosql.Session)4