Search in sources :

Example 1 with BIGINT

use of io.prestosql.spi.type.BigintType.BIGINT 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();
}
Also used : Symbol(io.prestosql.spi.plan.Symbol) TINY_SCALE_FACTOR(io.prestosql.plugin.tpch.TpchMetadata.TINY_SCALE_FACTOR) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) PlanBuilder.constantExpressions(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder.constantExpressions) ImmutableMap(com.google.common.collect.ImmutableMap) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Assignments(io.prestosql.spi.plan.Assignments) QualifiedName(io.prestosql.sql.tree.QualifiedName) CatalogName(io.prestosql.spi.connector.CatalogName) FunctionCallBuilder(io.prestosql.sql.planner.FunctionCallBuilder) Test(org.testng.annotations.Test) TableHandle(io.prestosql.spi.metadata.TableHandle) AggregationNode(io.prestosql.spi.plan.AggregationNode) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) ImmutableList(com.google.common.collect.ImmutableList) SymbolReference(io.prestosql.sql.tree.SymbolReference) Optional(java.util.Optional) DOUBLE(io.prestosql.spi.type.DoubleType.DOUBLE) TpchTransactionHandle(io.prestosql.plugin.tpch.TpchTransactionHandle) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) AggregationNode.singleGroupingSet(io.prestosql.spi.plan.AggregationNode.singleGroupingSet) FunctionCallBuilder(io.prestosql.sql.planner.FunctionCallBuilder) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 2 with BIGINT

use of io.prestosql.spi.type.BigintType.BIGINT in project hetu-core by openlookeng.

the class TestPushPredicateIntoTableScan method replaceWithExistsWhenNoLayoutExist.

@Test
public void replaceWithExistsWhenNoLayoutExist() {
    ColumnHandle columnHandle = new TpchColumnHandle("nationkey", BIGINT);
    tester().assertThat(pushPredicateIntoTableScan).on(p -> {
        p.symbol("nationkey", BIGINT);
        return p.filter(p.rowExpression("nationkey = BIGINT '44'"), p.tableScan(nationTableHandle, ImmutableList.of(p.symbol("nationkey", BIGINT)), ImmutableMap.of(p.symbol("nationkey", BIGINT), columnHandle), TupleDomain.none()));
    }).matches(values("A"));
}
Also used : TpchTableLayoutHandle(io.prestosql.plugin.tpch.TpchTableLayoutHandle) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) TpchTableHandle(io.prestosql.plugin.tpch.TpchTableHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) Test(org.testng.annotations.Test) SqlParser(io.prestosql.sql.parser.SqlParser) TableHandle(io.prestosql.spi.metadata.TableHandle) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Domain.singleValue(io.prestosql.spi.predicate.Domain.singleValue) TpchTransactionHandle(io.prestosql.plugin.tpch.TpchTransactionHandle) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Type(io.prestosql.spi.type.Type) PlanMatchPattern.filter(io.prestosql.sql.planner.assertions.PlanMatchPattern.filter) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) ImmutableMap(com.google.common.collect.ImmutableMap) TupleDomain(io.prestosql.spi.predicate.TupleDomain) BeforeClass(org.testng.annotations.BeforeClass) CatalogName(io.prestosql.spi.connector.CatalogName) VarcharType.createVarcharType(io.prestosql.spi.type.VarcharType.createVarcharType) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Domain(io.prestosql.spi.predicate.Domain) Optional(java.util.Optional) PlanMatchPattern.constrainedTableScanWithTableLayout(io.prestosql.sql.planner.assertions.PlanMatchPattern.constrainedTableScanWithTableLayout) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TpchColumnHandle(io.prestosql.plugin.tpch.TpchColumnHandle) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 3 with BIGINT

use of io.prestosql.spi.type.BigintType.BIGINT in project hetu-core by openlookeng.

the class TestPushProjectionThroughUnion method test.

@Test
public void test() {
    FunctionResolution functionResolution = new FunctionResolution(tester().getMetadata().getFunctionAndTypeManager());
    tester().assertThat(new PushProjectionThroughUnion()).on(p -> {
        Symbol a = p.symbol("a");
        Symbol b = p.symbol("b");
        Symbol c = p.symbol("c");
        Symbol cTimes3 = p.symbol("c_times_3");
        return p.project(Assignments.of(cTimes3, call("c * 3", functionResolution.arithmeticFunction(MULTIPLY, BIGINT, BIGINT), BIGINT, p.variable("c"), constant(3L, BIGINT))), p.union(ImmutableListMultimap.<Symbol, Symbol>builder().put(c, a).put(c, b).build(), ImmutableList.of(p.values(a), p.values(b))));
    }).matches(union(project(ImmutableMap.of("a_times_3", expression("a * 3")), values(ImmutableList.of("a"))), project(ImmutableMap.of("b_times_3", expression("b * 3")), values(ImmutableList.of("b")))).withNumberOfOutputColumns(1).withAlias("a_times_3").withAlias("b_times_3"));
}
Also used : Symbol(io.prestosql.spi.plan.Symbol) MULTIPLY(io.prestosql.spi.function.OperatorType.MULTIPLY) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) PlanMatchPattern.project(io.prestosql.sql.planner.assertions.PlanMatchPattern.project) Expressions.constant(io.prestosql.sql.relational.Expressions.constant) ImmutableMap(com.google.common.collect.ImmutableMap) Assignments(io.prestosql.spi.plan.Assignments) PlanMatchPattern.union(io.prestosql.sql.planner.assertions.PlanMatchPattern.union) Test(org.testng.annotations.Test) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) ImmutableList(com.google.common.collect.ImmutableList) LongLiteral(io.prestosql.sql.tree.LongLiteral) Expressions.call(io.prestosql.sql.relational.Expressions.call) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) PlanMatchPattern.expression(io.prestosql.sql.planner.assertions.PlanMatchPattern.expression) OriginalExpressionUtils(io.prestosql.sql.relational.OriginalExpressionUtils) Symbol(io.prestosql.spi.plan.Symbol) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 4 with BIGINT

use of io.prestosql.spi.type.BigintType.BIGINT in project hetu-core by openlookeng.

the class TestRemoveAggregationInSemiJoin method semiJoinWithAggregationAsFilteringSource.

private static PlanNode semiJoinWithAggregationAsFilteringSource(PlanBuilder p) {
    Symbol leftKey = p.symbol("leftKey");
    Symbol rightKey = p.symbol("rightKey");
    return p.semiJoin(leftKey, rightKey, p.symbol("match"), Optional.empty(), Optional.empty(), p.values(leftKey), p.aggregation(builder -> builder.globalGrouping().addAggregation(rightKey, expression("count(rightValue)"), ImmutableList.of(BIGINT)).source(p.values(p.symbol("rightValue")))));
}
Also used : Symbol(io.prestosql.spi.plan.Symbol) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) ImmutableList(com.google.common.collect.ImmutableList) PlanMatchPattern.semiJoin(io.prestosql.sql.planner.assertions.PlanMatchPattern.semiJoin) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test) PlanNode(io.prestosql.spi.plan.PlanNode) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) PlanBuilder.expression(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder.expression) Symbol(io.prestosql.spi.plan.Symbol)

Example 5 with BIGINT

use of io.prestosql.spi.type.BigintType.BIGINT in project hetu-core by openlookeng.

the class TestPruneWindowColumns method buildProjectedWindow.

private static PlanNode buildProjectedWindow(PlanBuilder p, Predicate<Symbol> projectionFilter, Predicate<Symbol> sourceFilter) {
    Symbol orderKey = p.symbol("orderKey");
    Symbol partitionKey = p.symbol("partitionKey");
    Symbol hash = p.symbol("hash");
    Symbol startValue1 = p.symbol("startValue1");
    Symbol startValue2 = p.symbol("startValue2");
    Symbol endValue1 = p.symbol("endValue1");
    Symbol endValue2 = p.symbol("endValue2");
    Symbol input1 = p.symbol("input1");
    Symbol input2 = p.symbol("input2");
    Symbol unused = p.symbol("unused");
    Symbol output1 = p.symbol("output1");
    Symbol output2 = p.symbol("output2");
    List<Symbol> inputs = ImmutableList.of(orderKey, partitionKey, hash, startValue1, startValue2, endValue1, endValue2, input1, input2, unused);
    List<Symbol> outputs = ImmutableList.<Symbol>builder().addAll(inputs).add(output1, output2).build();
    return p.project(Assignments.copyOf(outputs.stream().filter(projectionFilter).collect(Collectors.toMap(v -> v, v -> p.variable(v.getName(), BIGINT)))), p.window(new WindowNode.Specification(ImmutableList.of(partitionKey), Optional.of(new OrderingScheme(ImmutableList.of(orderKey), ImmutableMap.of(orderKey, SortOrder.ASC_NULLS_FIRST)))), ImmutableMap.of(output1, new WindowNode.Function(call(FUNCTION_NAME, FUNCTION_HANDLE, BIGINT, ImmutableList.of(p.variable(input1.getName()))), ImmutableList.of(p.variable(input1.getName())), new WindowNode.Frame(WindowFrameType.RANGE, UNBOUNDED_PRECEDING, Optional.of(startValue1), CURRENT_ROW, Optional.of(endValue1), Optional.of(startValue1.getName()), Optional.of(endValue2.getName()))), output2, new WindowNode.Function(call(FUNCTION_NAME, FUNCTION_HANDLE, BIGINT, ImmutableList.of(p.variable(input2.getName()))), ImmutableList.of(p.variable(input2.getName())), new WindowNode.Frame(WindowFrameType.RANGE, UNBOUNDED_PRECEDING, Optional.of(startValue2), CURRENT_ROW, Optional.of(endValue2), Optional.of(startValue2.getName()), Optional.of(endValue2.getName())))), hash, p.values(inputs.stream().filter(sourceFilter).collect(toImmutableList()), ImmutableList.of())));
}
Also used : BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) UNBOUNDED_PRECEDING(io.prestosql.spi.sql.expression.Types.FrameBoundType.UNBOUNDED_PRECEDING) Test(org.testng.annotations.Test) SortOrder(io.prestosql.spi.block.SortOrder) Predicates.alwaysTrue(com.google.common.base.Predicates.alwaysTrue) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) PlanMatchPattern.windowFrame(io.prestosql.sql.planner.assertions.PlanMatchPattern.windowFrame) ImmutableList(com.google.common.collect.ImmutableList) Expressions.call(io.prestosql.sql.relational.Expressions.call) OrderingScheme(io.prestosql.spi.plan.OrderingScheme) PlanMatchPattern.functionCall(io.prestosql.sql.planner.assertions.PlanMatchPattern.functionCall) ExpectedValueProvider(io.prestosql.sql.planner.assertions.ExpectedValueProvider) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) PlanMatchPattern.expression(io.prestosql.sql.planner.assertions.PlanMatchPattern.expression) PlanMatchPattern.window(io.prestosql.sql.planner.assertions.PlanMatchPattern.window) Symbol(io.prestosql.spi.plan.Symbol) ImmutableSet(com.google.common.collect.ImmutableSet) TypeSignatureProvider.fromTypes(io.prestosql.sql.analyzer.TypeSignatureProvider.fromTypes) WindowFrameType(io.prestosql.spi.sql.expression.Types.WindowFrameType) ImmutableMap(com.google.common.collect.ImmutableMap) Assignments(io.prestosql.spi.plan.Assignments) PlanMatchPattern.strictProject(io.prestosql.sql.planner.assertions.PlanMatchPattern.strictProject) Predicate(java.util.function.Predicate) MetadataManager.createTestMetadataManager(io.prestosql.metadata.MetadataManager.createTestMetadataManager) PlanMatchPattern(io.prestosql.sql.planner.assertions.PlanMatchPattern) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) PlanNode(io.prestosql.spi.plan.PlanNode) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) FunctionHandle(io.prestosql.spi.function.FunctionHandle) List(java.util.List) WindowNode(io.prestosql.spi.plan.WindowNode) Optional(java.util.Optional) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) CURRENT_ROW(io.prestosql.spi.sql.expression.Types.FrameBoundType.CURRENT_ROW) OrderingScheme(io.prestosql.spi.plan.OrderingScheme) WindowNode(io.prestosql.spi.plan.WindowNode) PlanMatchPattern.windowFrame(io.prestosql.sql.planner.assertions.PlanMatchPattern.windowFrame) Symbol(io.prestosql.spi.plan.Symbol)

Aggregations

BIGINT (io.prestosql.spi.type.BigintType.BIGINT)59 ImmutableList (com.google.common.collect.ImmutableList)51 Test (org.testng.annotations.Test)48 Optional (java.util.Optional)47 ImmutableMap (com.google.common.collect.ImmutableMap)43 Symbol (io.prestosql.spi.plan.Symbol)36 List (java.util.List)28 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)21 Type (io.prestosql.spi.type.Type)21 PlanMatchPattern.values (io.prestosql.sql.planner.assertions.PlanMatchPattern.values)21 Assignments (io.prestosql.spi.plan.Assignments)19 Assert.assertTrue (org.testng.Assert.assertTrue)19 VARCHAR (io.prestosql.spi.type.VarcharType.VARCHAR)18 ArrayList (java.util.ArrayList)18 Assert.assertEquals (org.testng.Assert.assertEquals)17 Metadata (io.prestosql.metadata.Metadata)16 BeforeClass (org.testng.annotations.BeforeClass)16 BaseRuleTest (io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest)15 Assert.assertFalse (org.testng.Assert.assertFalse)15 MetadataManager.createTestMetadataManager (io.prestosql.metadata.MetadataManager.createTestMetadataManager)14