Search in sources :

Example 1 with FIRST

use of io.prestosql.sql.tree.SortItem.NullOrdering.FIRST in project hetu-core by openlookeng.

the class TestPushTopNThroughProject method testPushdownTopNNonIdentityProjectionWithExpression.

@Test
public void testPushdownTopNNonIdentityProjectionWithExpression() {
    Signature signature = internalOperator(OperatorType.ADD, BIGINT.getTypeSignature(), BIGINT.getTypeSignature());
    FunctionResolution functionResolution = new FunctionResolution(METADATA.getFunctionAndTypeManager());
    tester().assertThat(new PushTopNThroughProject()).on(p -> {
        Symbol projectedA = p.symbol("projectedA");
        Symbol a = p.symbol("a");
        Symbol projectedC = p.symbol("projectedC");
        Symbol b = p.symbol("b");
        return p.topN(1, ImmutableList.of(projectedA), p.project(Assignments.of(projectedA, p.variable("a"), projectedC, call(OperatorType.ADD.name(), functionResolution.arithmeticFunction(OperatorType.ADD, BIGINT, BIGINT), BIGINT, Expressions.variable("a", BIGINT), Expressions.variable("b", BIGINT))), p.values(a, b)));
    }).matches(project(ImmutableMap.of("projectedA", new ExpressionMatcher("a"), "projectedC", new ExpressionMatcher("a + b")), topN(1, ImmutableList.of(sort("a", ASCENDING, FIRST)), values("a", "b"))));
}
Also used : BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) PlanMatchPattern.project(io.prestosql.sql.planner.assertions.PlanMatchPattern.project) TestingMetadata(io.prestosql.testing.TestingMetadata) Test(org.testng.annotations.Test) PlanMatchPattern.values(io.prestosql.sql.planner.assertions.PlanMatchPattern.values) ImmutableList(com.google.common.collect.ImmutableList) Expressions.call(io.prestosql.sql.relational.Expressions.call) BooleanLiteral(io.prestosql.sql.tree.BooleanLiteral) Signature.internalOperator(io.prestosql.spi.function.Signature.internalOperator) OperatorType(io.prestosql.spi.function.OperatorType) Signature(io.prestosql.spi.function.Signature) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) Symbol(io.prestosql.spi.plan.Symbol) ASCENDING(io.prestosql.sql.tree.SortItem.Ordering.ASCENDING) ImmutableMap(com.google.common.collect.ImmutableMap) Assignments(io.prestosql.spi.plan.Assignments) MetadataManager.createTestMetadataManager(io.prestosql.metadata.MetadataManager.createTestMetadataManager) ExpressionMatcher(io.prestosql.sql.planner.assertions.ExpressionMatcher) Metadata(io.prestosql.metadata.Metadata) Expressions(io.prestosql.sql.relational.Expressions) Expressions.variable(io.prestosql.sql.relational.Expressions.variable) PlanMatchPattern.sort(io.prestosql.sql.planner.assertions.PlanMatchPattern.sort) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) FIRST(io.prestosql.sql.tree.SortItem.NullOrdering.FIRST) PlanMatchPattern.topN(io.prestosql.sql.planner.assertions.PlanMatchPattern.topN) ExpressionMatcher(io.prestosql.sql.planner.assertions.ExpressionMatcher) Symbol(io.prestosql.spi.plan.Symbol) Signature(io.prestosql.spi.function.Signature) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Metadata (io.prestosql.metadata.Metadata)1 MetadataManager.createTestMetadataManager (io.prestosql.metadata.MetadataManager.createTestMetadataManager)1 OperatorType (io.prestosql.spi.function.OperatorType)1 Signature (io.prestosql.spi.function.Signature)1 Signature.internalOperator (io.prestosql.spi.function.Signature.internalOperator)1 Assignments (io.prestosql.spi.plan.Assignments)1 Symbol (io.prestosql.spi.plan.Symbol)1 BIGINT (io.prestosql.spi.type.BigintType.BIGINT)1 ExpressionMatcher (io.prestosql.sql.planner.assertions.ExpressionMatcher)1 PlanMatchPattern.project (io.prestosql.sql.planner.assertions.PlanMatchPattern.project)1 PlanMatchPattern.sort (io.prestosql.sql.planner.assertions.PlanMatchPattern.sort)1 PlanMatchPattern.topN (io.prestosql.sql.planner.assertions.PlanMatchPattern.topN)1 PlanMatchPattern.values (io.prestosql.sql.planner.assertions.PlanMatchPattern.values)1 BaseRuleTest (io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest)1 Expressions (io.prestosql.sql.relational.Expressions)1 Expressions.call (io.prestosql.sql.relational.Expressions.call)1 Expressions.variable (io.prestosql.sql.relational.Expressions.variable)1 FunctionResolution (io.prestosql.sql.relational.FunctionResolution)1