Search in sources :

Example 1 with FINAL

use of io.trino.sql.planner.plan.AggregationNode.Step.FINAL in project trino by trinodb.

the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoin.

@Test
public void testWithPartialAggregationBelowJoin() {
    Symbol symbol = new Symbol("symbol");
    PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(builder.join(INNER, builder.exchange(e -> e.type(REPARTITION).scope(LOCAL).fixedHashDistributionParitioningScheme(ImmutableList.of(symbol), ImmutableList.of(symbol)).addInputsSet(symbol).addSource(builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(tableScanNode)))), builder.values())));
    validatePlan(root, true);
}
Also used : TypeAnalyzer.createTestingTypeAnalyzer(io.trino.sql.planner.TypeAnalyzer.createTestingTypeAnalyzer) INNER(io.trino.sql.planner.plan.JoinNode.Type.INNER) Test(org.testng.annotations.Test) PlanNode(io.trino.sql.planner.plan.PlanNode) CatalogName(io.trino.connector.CatalogName) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) TpchTableHandle(io.trino.plugin.tpch.TpchTableHandle) LOCAL(io.trino.sql.planner.plan.ExchangeNode.Scope.LOCAL) PlanBuilder(io.trino.sql.planner.iterative.rule.test.PlanBuilder) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) REPARTITION(io.trino.sql.planner.plan.ExchangeNode.Type.REPARTITION) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest) TableScanNode(io.trino.sql.planner.plan.TableScanNode) PARTIAL(io.trino.sql.planner.plan.AggregationNode.Step.PARTIAL) Symbol(io.trino.sql.planner.Symbol) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) TestingTransactionHandle(io.trino.testing.TestingTransactionHandle) AggregationNode.groupingSets(io.trino.sql.planner.plan.AggregationNode.groupingSets) TableHandle(io.trino.metadata.TableHandle) BIGINT(io.trino.spi.type.BigintType.BIGINT) REMOTE(io.trino.sql.planner.plan.ExchangeNode.Scope.REMOTE) WarningCollector(io.trino.execution.warnings.WarningCollector) TypeProvider(io.trino.sql.planner.TypeProvider) FINAL(io.trino.sql.planner.plan.AggregationNode.Step.FINAL) PlanNodeIdAllocator(io.trino.sql.planner.PlanNodeIdAllocator) PlannerContext(io.trino.sql.PlannerContext) PlanNode(io.trino.sql.planner.plan.PlanNode) Symbol(io.trino.sql.planner.Symbol) Test(org.testng.annotations.Test) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest)

Example 2 with FINAL

use of io.trino.sql.planner.plan.AggregationNode.Step.FINAL in project trino by trinodb.

the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoinWithoutSeparatingExchange.

@Test
public void testWithPartialAggregationBelowJoinWithoutSeparatingExchange() {
    Symbol symbol = new Symbol("symbol");
    PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(builder.join(INNER, builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(tableScanNode)), builder.values())));
    assertThatThrownBy(() -> validatePlan(root, true)).isInstanceOf(IllegalArgumentException.class).hasMessage("Final aggregation with default value not separated from partial aggregation by local hash exchange");
}
Also used : TypeAnalyzer.createTestingTypeAnalyzer(io.trino.sql.planner.TypeAnalyzer.createTestingTypeAnalyzer) INNER(io.trino.sql.planner.plan.JoinNode.Type.INNER) Test(org.testng.annotations.Test) PlanNode(io.trino.sql.planner.plan.PlanNode) CatalogName(io.trino.connector.CatalogName) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) TpchTableHandle(io.trino.plugin.tpch.TpchTableHandle) LOCAL(io.trino.sql.planner.plan.ExchangeNode.Scope.LOCAL) PlanBuilder(io.trino.sql.planner.iterative.rule.test.PlanBuilder) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) REPARTITION(io.trino.sql.planner.plan.ExchangeNode.Type.REPARTITION) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest) TableScanNode(io.trino.sql.planner.plan.TableScanNode) PARTIAL(io.trino.sql.planner.plan.AggregationNode.Step.PARTIAL) Symbol(io.trino.sql.planner.Symbol) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) TestingTransactionHandle(io.trino.testing.TestingTransactionHandle) AggregationNode.groupingSets(io.trino.sql.planner.plan.AggregationNode.groupingSets) TableHandle(io.trino.metadata.TableHandle) BIGINT(io.trino.spi.type.BigintType.BIGINT) REMOTE(io.trino.sql.planner.plan.ExchangeNode.Scope.REMOTE) WarningCollector(io.trino.execution.warnings.WarningCollector) TypeProvider(io.trino.sql.planner.TypeProvider) FINAL(io.trino.sql.planner.plan.AggregationNode.Step.FINAL) PlanNodeIdAllocator(io.trino.sql.planner.PlanNodeIdAllocator) PlannerContext(io.trino.sql.PlannerContext) PlanNode(io.trino.sql.planner.plan.PlanNode) Symbol(io.trino.sql.planner.Symbol) Test(org.testng.annotations.Test) BasePlanTest(io.trino.sql.planner.assertions.BasePlanTest)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 TEST_SESSION (io.trino.SessionTestUtils.TEST_SESSION)2 CatalogName (io.trino.connector.CatalogName)2 WarningCollector (io.trino.execution.warnings.WarningCollector)2 TableHandle (io.trino.metadata.TableHandle)2 TpchColumnHandle (io.trino.plugin.tpch.TpchColumnHandle)2 TpchTableHandle (io.trino.plugin.tpch.TpchTableHandle)2 BIGINT (io.trino.spi.type.BigintType.BIGINT)2 PlannerContext (io.trino.sql.PlannerContext)2 PlanNodeIdAllocator (io.trino.sql.planner.PlanNodeIdAllocator)2 Symbol (io.trino.sql.planner.Symbol)2 TypeAnalyzer.createTestingTypeAnalyzer (io.trino.sql.planner.TypeAnalyzer.createTestingTypeAnalyzer)2 TypeProvider (io.trino.sql.planner.TypeProvider)2 BasePlanTest (io.trino.sql.planner.assertions.BasePlanTest)2 PlanBuilder (io.trino.sql.planner.iterative.rule.test.PlanBuilder)2 FINAL (io.trino.sql.planner.plan.AggregationNode.Step.FINAL)2 PARTIAL (io.trino.sql.planner.plan.AggregationNode.Step.PARTIAL)2 AggregationNode.groupingSets (io.trino.sql.planner.plan.AggregationNode.groupingSets)2