Search in sources :

Example 6 with FeaturesConfig

use of io.prestosql.sql.analyzer.FeaturesConfig 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)

Example 7 with FeaturesConfig

use of io.prestosql.sql.analyzer.FeaturesConfig in project hetu-core by openlookeng.

the class TestStarTreeMetaStore method setup.

@BeforeClass
public void setup() {
    FeaturesConfig featuresConfig = new FeaturesConfig();
    featuresConfig.setCubeMetadataCacheTtl(Duration.valueOf("5m"));
    featuresConfig.setCubeMetadataCacheSize(1000);
    Properties properties = new Properties();
    properties.setProperty("cache-ttl", Long.toString(featuresConfig.getCubeMetadataCacheTtl().toMillis()));
    properties.setProperty("cache-size", Long.toString(featuresConfig.getCubeMetadataCacheSize()));
    metaStore = new MockMetaStore();
    cubeMetadataService = new StarTreeProvider().getCubeMetaStore(metaStore, properties);
    cubeMetadata1 = new StarTreeMetadata("star1", "a", 1000, ImmutableList.of(new AggregateColumn("sum_cost", "SUM", "cost", false), new DimensionColumn("value", "value")), ImmutableList.of(ImmutableSet.of("value")), null, 10000, CubeStatus.READY);
    cubeMetadata2 = new StarTreeMetadata("star2", "a", 1000, ImmutableList.of(new AggregateColumn("sum_cost", "SUM", "cost", false), new DimensionColumn("value", "value")), ImmutableList.of(ImmutableSet.of("value")), null, 10000, CubeStatus.READY);
}
Also used : StarTreeProvider(io.hetu.core.cube.startree.StarTreeProvider) StarTreeMetadata(io.hetu.core.cube.startree.tree.StarTreeMetadata) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) DimensionColumn(io.hetu.core.cube.startree.tree.DimensionColumn) Properties(java.util.Properties) AggregateColumn(io.hetu.core.cube.startree.tree.AggregateColumn) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with FeaturesConfig

use of io.prestosql.sql.analyzer.FeaturesConfig in project hetu-core by openlookeng.

the class TestAddExchangesPlans method createQueryRunner.

private static LocalQueryRunner createQueryRunner() {
    Session session = testSessionBuilder().setCatalog("tpch").setSchema("tiny").build();
    FeaturesConfig featuresConfig = new FeaturesConfig().setSpillerSpillPaths("/tmp/test_spill_path");
    LocalQueryRunner queryRunner = new LocalQueryRunner(session, featuresConfig);
    queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    return queryRunner;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Session(io.prestosql.Session)

Example 9 with FeaturesConfig

use of io.prestosql.sql.analyzer.FeaturesConfig in project hetu-core by openlookeng.

the class TestPruneCTENodes method createQueryRunner.

private static LocalQueryRunner createQueryRunner() {
    Session session = testSessionBuilder().setCatalog("tpch").setSchema("tiny").build();
    FeaturesConfig featuresConfig = new FeaturesConfig().setSpillerSpillPaths("/tmp/test_spill_path");
    LocalQueryRunner queryRunner = new LocalQueryRunner(session, featuresConfig);
    queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    return queryRunner;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Session(io.prestosql.Session)

Example 10 with FeaturesConfig

use of io.prestosql.sql.analyzer.FeaturesConfig in project hetu-core by openlookeng.

the class AbstractTestQueryFramework method getQueryExplainer.

private QueryExplainer getQueryExplainer() {
    Metadata metadata = queryRunner.getMetadata();
    FeaturesConfig featuresConfig = new FeaturesConfig().setOptimizeHashGeneration(true);
    boolean forceSingleNode = queryRunner.getNodeCount() == 1;
    TaskCountEstimator taskCountEstimator = new TaskCountEstimator(queryRunner::getNodeCount);
    CostCalculator costCalculator = new CostCalculatorUsingExchanges(taskCountEstimator);
    HetuMetaStoreManager hetuMetaStoreManager = new HetuMetaStoreManager();
    List<PlanOptimizer> optimizers = new PlanOptimizers(metadata, new TypeAnalyzer(sqlParser, metadata), featuresConfig, new TaskManagerConfig(), forceSingleNode, new MBeanExporter(new TestingMBeanServer()), queryRunner.getSplitManager(), queryRunner.getPlanOptimizerManager(), queryRunner.getPageSourceManager(), queryRunner.getStatsCalculator(), costCalculator, new CostCalculatorWithEstimatedExchanges(costCalculator, taskCountEstimator), new CostComparator(featuresConfig), taskCountEstimator, new CubeManager(featuresConfig, hetuMetaStoreManager)).get();
    return new QueryExplainer(optimizers, new PlanFragmenter(metadata, queryRunner.getNodePartitioningManager(), new QueryManagerConfig()), metadata, queryRunner.getAccessControl(), sqlParser, queryRunner.getStatsCalculator(), costCalculator, ImmutableMap.of(), new HeuristicIndexerManager(null, null), new CubeManager(featuresConfig, hetuMetaStoreManager));
}
Also used : TaskCountEstimator(io.prestosql.cost.TaskCountEstimator) CostComparator(io.prestosql.cost.CostComparator) PlanOptimizer(io.prestosql.sql.planner.optimizations.PlanOptimizer) TestingMBeanServer(org.weakref.jmx.testing.TestingMBeanServer) QueryExplainer(io.prestosql.sql.analyzer.QueryExplainer) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) MBeanExporter(org.weakref.jmx.MBeanExporter) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) Metadata(io.prestosql.metadata.Metadata) PlanFragmenter(io.prestosql.sql.planner.PlanFragmenter) TaskManagerConfig(io.prestosql.execution.TaskManagerConfig) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) CubeManager(io.prestosql.cube.CubeManager) CostCalculator(io.prestosql.cost.CostCalculator) PlanOptimizers(io.prestosql.sql.planner.PlanOptimizers) QueryManagerConfig(io.prestosql.execution.QueryManagerConfig) CostCalculatorUsingExchanges(io.prestosql.cost.CostCalculatorUsingExchanges) CostCalculatorWithEstimatedExchanges(io.prestosql.cost.CostCalculatorWithEstimatedExchanges) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager)

Aggregations

FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)10 BeforeClass (org.testng.annotations.BeforeClass)4 CubeManager (io.prestosql.cube.CubeManager)3 Metadata (io.prestosql.metadata.Metadata)3 TpchConnectorFactory (io.prestosql.plugin.tpch.TpchConnectorFactory)3 HetuLocalFileSystemClient (io.hetu.core.filesystem.HetuLocalFileSystemClient)2 LocalConfig (io.hetu.core.filesystem.LocalConfig)2 Session (io.prestosql.Session)2 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)2 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)2 HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)2 SqlParser (io.prestosql.sql.parser.SqlParser)2 LocalQueryRunner (io.prestosql.testing.LocalQueryRunner)2 IOException (java.io.IOException)2 Properties (java.util.Properties)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)1 NodeInfo (io.airlift.node.NodeInfo)1 StarTreeProvider (io.hetu.core.cube.startree.StarTreeProvider)1