use of io.prestosql.sql.planner.FunctionCallBuilder in project hetu-core by openlookeng.
the class TestPruneCountAggregationOverScalar method testDoesNotFireOnNestedCountAggregateWithNonEmptyGroupBy.
@Test
public void testDoesNotFireOnNestedCountAggregateWithNonEmptyGroupBy() {
tester().assertThat(new PruneCountAggregationOverScalar(getFunctionManager())).on(p -> p.aggregation((a) -> a.addAggregation(p.symbol("count_1", BIGINT), new FunctionCallBuilder(tester().getMetadata()).setName(QualifiedName.of("count")).build(), ImmutableList.of(BIGINT)).step(AggregationNode.Step.SINGLE).globalGrouping().source(p.aggregation(aggregationBuilder -> {
aggregationBuilder.source(p.tableScan(ImmutableList.of(), ImmutableMap.of())).groupingSets(singleGroupingSet(ImmutableList.of(p.symbol("orderkey"))));
aggregationBuilder.source(p.tableScan(ImmutableList.of(), ImmutableMap.of()));
})))).doesNotFire();
}
use of io.prestosql.sql.planner.FunctionCallBuilder in project hetu-core by openlookeng.
the class TestExpressionRewriteRuleSet method testAggregationExpressionRewrite.
@Test
public void testAggregationExpressionRewrite() {
ExpressionRewriteRuleSet functionCallRewriter = new ExpressionRewriteRuleSet((expression, context) -> new FunctionCallBuilder(tester().getMetadata()).setName(QualifiedName.of("count")).addArgument(VARCHAR, new SymbolReference("y")).build());
tester().assertThat(functionCallRewriter.aggregationExpressionRewrite()).on(p -> p.aggregation(a -> a.globalGrouping().addAggregation(p.symbol("count_1", BigintType.BIGINT), new FunctionCallBuilder(tester().getMetadata()).setName(QualifiedName.of("count")).addArgument(VARCHAR, new SymbolReference("x")).build(), ImmutableList.of(BigintType.BIGINT)).source(p.values(p.symbol("x"), p.symbol("y"))))).matches(PlanMatchPattern.aggregation(ImmutableMap.of("count_1", aliases -> new FunctionCallBuilder(tester().getMetadata()).setName(QualifiedName.of("count")).addArgument(VARCHAR, new SymbolReference("y")).build()), values("x", "y")));
}
use of io.prestosql.sql.planner.FunctionCallBuilder 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.sql.planner.FunctionCallBuilder 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.sql.planner.FunctionCallBuilder in project hetu-core by openlookeng.
the class TestScalarStatsCalculator method testFunctionCall.
@Test
public void testFunctionCall() {
assertCalculate(new FunctionCallBuilder(metadata).setName(QualifiedName.of("length")).addArgument(createVarcharType(10), new Cast(new NullLiteral(), "VARCHAR(10)")).build()).distinctValuesCount(0.0).lowValueUnknown().highValueUnknown().nullsFraction(1.0);
assertCalculate(new FunctionCallBuilder(metadata).setName(QualifiedName.of("length")).addArgument(createVarcharType(2), new SymbolReference("x")).build(), PlanNodeStatsEstimate.unknown(), TypeProvider.viewOf(ImmutableMap.of(new Symbol("x"), createVarcharType(2)))).distinctValuesCountUnknown().lowValueUnknown().highValueUnknown().nullsFractionUnknown();
}
Aggregations