Search in sources :

Example 6 with TpchColumnHandle

use of io.prestosql.plugin.tpch.TpchColumnHandle 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"));
}
Also used : BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Arrays(java.util.Arrays) ListMultimap(com.google.common.collect.ListMultimap) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) QualifiedName(io.prestosql.sql.tree.QualifiedName) FunctionCallBuilder(io.prestosql.sql.planner.FunctionCallBuilder) Test(org.testng.annotations.Test) AggregationNode(io.prestosql.spi.plan.AggregationNode) Cast(io.prestosql.sql.tree.Cast) FilterNode(io.prestosql.spi.plan.FilterNode) ENABLE_STAR_TREE_INDEX(io.prestosql.SystemSessionProperties.ENABLE_STAR_TREE_INDEX) Matchers.eq(org.mockito.Matchers.eq) Map(java.util.Map) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) PlanBuilder.expression(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder.expression) Assert.assertFalse(org.testng.Assert.assertFalse) AggregationNode.singleGroupingSet(io.prestosql.spi.plan.AggregationNode.singleGroupingSet) CubeMetaStore(io.hetu.core.spi.cube.io.CubeMetaStore) SymbolUtils(io.prestosql.sql.planner.SymbolUtils) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) ImmutableMap(com.google.common.collect.ImmutableMap) MetadataManager.createTestMetadataManager(io.prestosql.metadata.MetadataManager.createTestMetadataManager) BeforeClass(org.testng.annotations.BeforeClass) TableScanNode(io.prestosql.spi.plan.TableScanNode) PlanNode(io.prestosql.spi.plan.PlanNode) UUID(java.util.UUID) CubeStatement(io.hetu.core.spi.cube.CubeStatement) ProjectNode(io.prestosql.spi.plan.ProjectNode) Metadata(io.prestosql.metadata.Metadata) FunctionHandle(io.prestosql.spi.function.FunctionHandle) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) Matchers.any(org.mockito.Matchers.any) ReuseExchangeOperator(io.prestosql.spi.operator.ReuseExchangeOperator) List(java.util.List) DoubleLiteral(io.prestosql.sql.tree.DoubleLiteral) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Returns(org.mockito.internal.stubbing.answers.Returns) UnionNode(io.prestosql.spi.plan.UnionNode) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) FunctionAndTypeManager(io.prestosql.metadata.FunctionAndTypeManager) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableMetadata(io.prestosql.metadata.TableMetadata) StandardTypes(io.prestosql.spi.type.StandardTypes) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) INTEGER(io.prestosql.spi.type.IntegerType.INTEGER) AbstractMockMetadata.dummyMetadata(io.prestosql.metadata.AbstractMockMetadata.dummyMetadata) TableHandle(io.prestosql.spi.metadata.TableHandle) Matchers.anyString(org.mockito.Matchers.anyString) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) ArrayList(java.util.ArrayList) BaseMatcher(org.hamcrest.BaseMatcher) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) SINGLE(io.prestosql.spi.plan.AggregationNode.Step.SINGLE) DateTimeUtils(io.prestosql.spi.util.DateTimeUtils) Session(io.prestosql.Session) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) TpchTransactionHandle(io.prestosql.plugin.tpch.TpchTransactionHandle) DATE(io.prestosql.spi.type.DateType.DATE) CubeProvider(io.prestosql.spi.cube.CubeProvider) Symbol(io.prestosql.spi.plan.Symbol) Description(org.hamcrest.Description) TypeSignatureProvider.fromTypes(io.prestosql.sql.analyzer.TypeSignatureProvider.fromTypes) Assignments(io.prestosql.spi.plan.Assignments) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) TupleDomain(io.prestosql.spi.predicate.TupleDomain) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) Expressions(io.prestosql.sql.relational.Expressions) CubeManager(io.prestosql.cube.CubeManager) Mockito(org.mockito.Mockito) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Matcher(org.hamcrest.Matcher) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) InputReferenceExpression(io.prestosql.spi.relation.InputReferenceExpression) RowExpression(io.prestosql.spi.relation.RowExpression) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) Assert.assertTrue(org.testng.Assert.assertTrue) Returns(org.mockito.internal.stubbing.answers.Returns) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) FunctionCallBuilder(io.prestosql.sql.planner.FunctionCallBuilder) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 7 with TpchColumnHandle

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

the class TestStarTreeAggregationRule method testDoNotUseCubeIfSourceTableUpdatedAfterCubeCreated.

@Test
public void testDoNotUseCubeIfSourceTableUpdatedAfterCubeCreated() {
    Mockito.when(cubeManager.getCubeProvider(anyString())).then(new Returns(Optional.of(provider)));
    Mockito.when(cubeManager.getMetaStore(anyString())).then(new Returns(Optional.of(cubeMetaStore)));
    Metadata metadata = Mockito.mock(Metadata.class);
    TableMetadata ordersTableMetadata = Mockito.mock(TableMetadata.class);
    QualifiedObjectName objectName = new QualifiedObjectName("local", "sf1.0", "orders");
    Mockito.when(metadata.getTableHandle(any(Session.class), eq(objectName))).thenReturn(Optional.of(ordersTableHandle));
    Mockito.when(metadata.getTableLastModifiedTimeSupplier(any(Session.class), any(TableHandle.class))).thenReturn(() -> DateTimeUtils.parseTimestampWithoutTimeZone("2020-01-02 12:00:00"));
    Mockito.when(metadata.getTableMetadata(any(Session.class), eq(ordersTableHandle))).thenReturn(ordersTableMetadata);
    Mockito.when(ordersTableMetadata.getQualifiedName()).thenReturn(objectName);
    List<CubeMetadata> metadataList = ImmutableList.of(cubeMetadata);
    Mockito.when(cubeMetaStore.getMetadataList(eq("local.sf1.0.orders"))).then(new Returns(metadataList));
    Mockito.when(cubeMetadata.matches(any(CubeStatement.class))).thenReturn(true);
    Mockito.when(cubeMetadata.getLastUpdatedTime()).thenReturn(DateTimeUtils.parseTimestampWithoutTimeZone("2020-01-01 12:00:00"));
    StarTreeAggregationRule starTreeAggregationRule = new StarTreeAggregationRule(cubeManager, metadata);
    tester().assertThat(starTreeAggregationRule).setSystemProperty(ENABLE_STAR_TREE_INDEX, "true").on(p -> p.aggregation(builder -> builder.step(SINGLE).addAggregation(new Symbol("count_orderkey"), PlanBuilder.expression("count(orderkey)"), ImmutableList.of(BIGINT)).singleGroupingSet(new Symbol("orderdate")).source(p.project(Assignments.builder().put(p.symbol("orderdate", DATE), p.variable("orderdate", DATE)).put(p.symbol("orderkey", BIGINT), p.variable("orderkey", BIGINT)).build(), p.tableScan(ordersTableHandle, ImmutableList.of(p.symbol("orderdate", DATE), p.symbol("orderkey", BIGINT)), ImmutableMap.of(p.symbol("orderkey", BIGINT), new TpchColumnHandle("orderkey", BIGINT), p.symbol("orderdate", DATE), new TpchColumnHandle("orderdate", DATE))))))).doesNotFire();
    Mockito.verify(cubeMetaStore, Mockito.atLeastOnce()).getMetadataList(eq("local.sf1.0.orders"));
    Mockito.verify(cubeMetadata, Mockito.atLeastOnce()).matches(any(CubeStatement.class));
}
Also used : TableMetadata(io.prestosql.metadata.TableMetadata) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Arrays(java.util.Arrays) ListMultimap(com.google.common.collect.ListMultimap) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) QualifiedName(io.prestosql.sql.tree.QualifiedName) FunctionCallBuilder(io.prestosql.sql.planner.FunctionCallBuilder) Test(org.testng.annotations.Test) AggregationNode(io.prestosql.spi.plan.AggregationNode) Cast(io.prestosql.sql.tree.Cast) FilterNode(io.prestosql.spi.plan.FilterNode) ENABLE_STAR_TREE_INDEX(io.prestosql.SystemSessionProperties.ENABLE_STAR_TREE_INDEX) Matchers.eq(org.mockito.Matchers.eq) Map(java.util.Map) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) PlanBuilder.expression(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder.expression) Assert.assertFalse(org.testng.Assert.assertFalse) AggregationNode.singleGroupingSet(io.prestosql.spi.plan.AggregationNode.singleGroupingSet) CubeMetaStore(io.hetu.core.spi.cube.io.CubeMetaStore) SymbolUtils(io.prestosql.sql.planner.SymbolUtils) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) ImmutableMap(com.google.common.collect.ImmutableMap) MetadataManager.createTestMetadataManager(io.prestosql.metadata.MetadataManager.createTestMetadataManager) BeforeClass(org.testng.annotations.BeforeClass) TableScanNode(io.prestosql.spi.plan.TableScanNode) PlanNode(io.prestosql.spi.plan.PlanNode) UUID(java.util.UUID) CubeStatement(io.hetu.core.spi.cube.CubeStatement) ProjectNode(io.prestosql.spi.plan.ProjectNode) Metadata(io.prestosql.metadata.Metadata) FunctionHandle(io.prestosql.spi.function.FunctionHandle) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) Matchers.any(org.mockito.Matchers.any) ReuseExchangeOperator(io.prestosql.spi.operator.ReuseExchangeOperator) List(java.util.List) DoubleLiteral(io.prestosql.sql.tree.DoubleLiteral) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Returns(org.mockito.internal.stubbing.answers.Returns) UnionNode(io.prestosql.spi.plan.UnionNode) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) FunctionAndTypeManager(io.prestosql.metadata.FunctionAndTypeManager) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableMetadata(io.prestosql.metadata.TableMetadata) StandardTypes(io.prestosql.spi.type.StandardTypes) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) INTEGER(io.prestosql.spi.type.IntegerType.INTEGER) AbstractMockMetadata.dummyMetadata(io.prestosql.metadata.AbstractMockMetadata.dummyMetadata) TableHandle(io.prestosql.spi.metadata.TableHandle) Matchers.anyString(org.mockito.Matchers.anyString) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) ArrayList(java.util.ArrayList) BaseMatcher(org.hamcrest.BaseMatcher) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) SINGLE(io.prestosql.spi.plan.AggregationNode.Step.SINGLE) DateTimeUtils(io.prestosql.spi.util.DateTimeUtils) Session(io.prestosql.Session) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) TpchTransactionHandle(io.prestosql.plugin.tpch.TpchTransactionHandle) DATE(io.prestosql.spi.type.DateType.DATE) CubeProvider(io.prestosql.spi.cube.CubeProvider) Symbol(io.prestosql.spi.plan.Symbol) Description(org.hamcrest.Description) TypeSignatureProvider.fromTypes(io.prestosql.sql.analyzer.TypeSignatureProvider.fromTypes) Assignments(io.prestosql.spi.plan.Assignments) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) TupleDomain(io.prestosql.spi.predicate.TupleDomain) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) Expressions(io.prestosql.sql.relational.Expressions) CubeManager(io.prestosql.cube.CubeManager) Mockito(org.mockito.Mockito) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Matcher(org.hamcrest.Matcher) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) InputReferenceExpression(io.prestosql.spi.relation.InputReferenceExpression) RowExpression(io.prestosql.spi.relation.RowExpression) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) Assert.assertTrue(org.testng.Assert.assertTrue) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) Metadata(io.prestosql.metadata.Metadata) TableMetadata(io.prestosql.metadata.TableMetadata) AbstractMockMetadata.dummyMetadata(io.prestosql.metadata.AbstractMockMetadata.dummyMetadata) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) CubeStatement(io.hetu.core.spi.cube.CubeStatement) Returns(org.mockito.internal.stubbing.answers.Returns) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) Session(io.prestosql.Session) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 8 with TpchColumnHandle

use of io.prestosql.plugin.tpch.TpchColumnHandle 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"));
}
Also used : BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Arrays(java.util.Arrays) ListMultimap(com.google.common.collect.ListMultimap) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) QualifiedName(io.prestosql.sql.tree.QualifiedName) FunctionCallBuilder(io.prestosql.sql.planner.FunctionCallBuilder) Test(org.testng.annotations.Test) AggregationNode(io.prestosql.spi.plan.AggregationNode) Cast(io.prestosql.sql.tree.Cast) FilterNode(io.prestosql.spi.plan.FilterNode) ENABLE_STAR_TREE_INDEX(io.prestosql.SystemSessionProperties.ENABLE_STAR_TREE_INDEX) Matchers.eq(org.mockito.Matchers.eq) Map(java.util.Map) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) PlanBuilder.expression(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder.expression) Assert.assertFalse(org.testng.Assert.assertFalse) AggregationNode.singleGroupingSet(io.prestosql.spi.plan.AggregationNode.singleGroupingSet) CubeMetaStore(io.hetu.core.spi.cube.io.CubeMetaStore) SymbolUtils(io.prestosql.sql.planner.SymbolUtils) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) ImmutableMap(com.google.common.collect.ImmutableMap) MetadataManager.createTestMetadataManager(io.prestosql.metadata.MetadataManager.createTestMetadataManager) BeforeClass(org.testng.annotations.BeforeClass) TableScanNode(io.prestosql.spi.plan.TableScanNode) PlanNode(io.prestosql.spi.plan.PlanNode) UUID(java.util.UUID) CubeStatement(io.hetu.core.spi.cube.CubeStatement) ProjectNode(io.prestosql.spi.plan.ProjectNode) Metadata(io.prestosql.metadata.Metadata) FunctionHandle(io.prestosql.spi.function.FunctionHandle) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) Matchers.any(org.mockito.Matchers.any) ReuseExchangeOperator(io.prestosql.spi.operator.ReuseExchangeOperator) List(java.util.List) DoubleLiteral(io.prestosql.sql.tree.DoubleLiteral) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Returns(org.mockito.internal.stubbing.answers.Returns) UnionNode(io.prestosql.spi.plan.UnionNode) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) FunctionAndTypeManager(io.prestosql.metadata.FunctionAndTypeManager) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableMetadata(io.prestosql.metadata.TableMetadata) StandardTypes(io.prestosql.spi.type.StandardTypes) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) INTEGER(io.prestosql.spi.type.IntegerType.INTEGER) AbstractMockMetadata.dummyMetadata(io.prestosql.metadata.AbstractMockMetadata.dummyMetadata) TableHandle(io.prestosql.spi.metadata.TableHandle) Matchers.anyString(org.mockito.Matchers.anyString) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) ArrayList(java.util.ArrayList) BaseMatcher(org.hamcrest.BaseMatcher) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) SINGLE(io.prestosql.spi.plan.AggregationNode.Step.SINGLE) DateTimeUtils(io.prestosql.spi.util.DateTimeUtils) Session(io.prestosql.Session) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) TpchTransactionHandle(io.prestosql.plugin.tpch.TpchTransactionHandle) DATE(io.prestosql.spi.type.DateType.DATE) CubeProvider(io.prestosql.spi.cube.CubeProvider) Symbol(io.prestosql.spi.plan.Symbol) Description(org.hamcrest.Description) TypeSignatureProvider.fromTypes(io.prestosql.sql.analyzer.TypeSignatureProvider.fromTypes) Assignments(io.prestosql.spi.plan.Assignments) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) TupleDomain(io.prestosql.spi.predicate.TupleDomain) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) Expressions(io.prestosql.sql.relational.Expressions) CubeManager(io.prestosql.cube.CubeManager) Mockito(org.mockito.Mockito) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Matcher(org.hamcrest.Matcher) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) InputReferenceExpression(io.prestosql.spi.relation.InputReferenceExpression) RowExpression(io.prestosql.spi.relation.RowExpression) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) CubeMetadata(io.hetu.core.spi.cube.CubeMetadata) Assert.assertTrue(org.testng.Assert.assertTrue) Returns(org.mockito.internal.stubbing.answers.Returns) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) FunctionCallBuilder(io.prestosql.sql.planner.FunctionCallBuilder) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 9 with TpchColumnHandle

use of io.prestosql.plugin.tpch.TpchColumnHandle 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 10 with TpchColumnHandle

use of io.prestosql.plugin.tpch.TpchColumnHandle 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)

Aggregations

TpchColumnHandle (io.prestosql.plugin.tpch.TpchColumnHandle)15 TpchTableHandle (io.prestosql.plugin.tpch.TpchTableHandle)14 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)13 TableHandle (io.prestosql.spi.metadata.TableHandle)13 ImmutableList (com.google.common.collect.ImmutableList)11 ImmutableMap (com.google.common.collect.ImmutableMap)11 Optional (java.util.Optional)11 BeforeClass (org.testng.annotations.BeforeClass)11 TpchTableLayoutHandle (io.prestosql.plugin.tpch.TpchTableLayoutHandle)10 Symbol (io.prestosql.spi.plan.Symbol)10 TupleDomain (io.prestosql.spi.predicate.TupleDomain)10 Test (org.testng.annotations.Test)10 TpchTransactionHandle (io.prestosql.plugin.tpch.TpchTransactionHandle)9 Map (java.util.Map)9 CatalogName (io.prestosql.spi.connector.CatalogName)8 TableScanNode (io.prestosql.spi.plan.TableScanNode)8 BIGINT (io.prestosql.spi.type.BigintType.BIGINT)8 PlanBuilder (io.prestosql.sql.planner.iterative.rule.test.PlanBuilder)8 PlanNode (io.prestosql.spi.plan.PlanNode)7 PlanNodeIdAllocator (io.prestosql.spi.plan.PlanNodeIdAllocator)7