Search in sources :

Example 21 with SymbolAllocator

use of io.trino.sql.planner.SymbolAllocator in project trino by trinodb.

the class TestStatisticAggregationsDescriptor method createTestDescriptor.

private static StatisticAggregationsDescriptor<Symbol> createTestDescriptor() {
    StatisticAggregationsDescriptor.Builder<Symbol> builder = StatisticAggregationsDescriptor.builder();
    SymbolAllocator symbolAllocator = new SymbolAllocator();
    for (String column : COLUMNS) {
        for (ColumnStatisticType type : ColumnStatisticType.values()) {
            builder.addColumnStatistic(new ColumnStatisticMetadata(column, type), testSymbol(symbolAllocator));
        }
        builder.addGrouping(column, testSymbol(symbolAllocator));
    }
    builder.addTableStatistic(ROW_COUNT, testSymbol(symbolAllocator));
    return builder.build();
}
Also used : SymbolAllocator(io.trino.sql.planner.SymbolAllocator) ColumnStatisticMetadata(io.trino.spi.statistics.ColumnStatisticMetadata) Symbol(io.trino.sql.planner.Symbol) ColumnStatisticType(io.trino.spi.statistics.ColumnStatisticType)

Example 22 with SymbolAllocator

use of io.trino.sql.planner.SymbolAllocator in project trino by trinodb.

the class TestWindowNode method setUp.

@BeforeClass
public void setUp() {
    symbolAllocator = new SymbolAllocator();
    columnA = symbolAllocator.newSymbol("a", BIGINT);
    columnB = symbolAllocator.newSymbol("b", BIGINT);
    columnC = symbolAllocator.newSymbol("c", BIGINT);
    sourceNode = new ValuesNode(newId(), ImmutableList.of(columnA, columnB, columnC), ImmutableList.of());
}
Also used : SymbolAllocator(io.trino.sql.planner.SymbolAllocator) BeforeClass(org.testng.annotations.BeforeClass)

Example 23 with SymbolAllocator

use of io.trino.sql.planner.SymbolAllocator in project trino by trinodb.

the class AbstractOperatorBenchmark method createHashProjectOperator.

protected final OperatorFactory createHashProjectOperator(int operatorId, PlanNodeId planNodeId, List<Type> types) {
    SymbolAllocator symbolAllocator = new SymbolAllocator();
    ImmutableMap.Builder<Symbol, Integer> symbolToInputMapping = ImmutableMap.builder();
    ImmutableList.Builder<PageProjection> projections = ImmutableList.builder();
    for (int channel = 0; channel < types.size(); channel++) {
        Symbol symbol = symbolAllocator.newSymbol("h" + channel, types.get(channel));
        symbolToInputMapping.put(symbol, channel);
        projections.add(new InputPageProjection(channel, types.get(channel)));
    }
    Map<Symbol, Type> symbolTypes = symbolAllocator.getTypes().allTypes();
    Optional<Expression> hashExpression = HashGenerationOptimizer.getHashExpression(session, localQueryRunner.getMetadata(), symbolAllocator, ImmutableList.copyOf(symbolTypes.keySet()));
    verify(hashExpression.isPresent());
    Map<NodeRef<Expression>, Type> expressionTypes = createTestingTypeAnalyzer(localQueryRunner.getPlannerContext()).getTypes(session, TypeProvider.copyOf(symbolTypes), hashExpression.get());
    RowExpression translated = translate(hashExpression.get(), expressionTypes, symbolToInputMapping.buildOrThrow(), localQueryRunner.getMetadata(), localQueryRunner.getFunctionManager(), session, false);
    PageFunctionCompiler functionCompiler = new PageFunctionCompiler(localQueryRunner.getFunctionManager(), 0);
    projections.add(functionCompiler.compileProjection(translated, Optional.empty()).get());
    return FilterAndProjectOperator.createOperatorFactory(operatorId, planNodeId, () -> new PageProcessor(Optional.empty(), projections.build()), ImmutableList.copyOf(Iterables.concat(types, ImmutableList.of(BIGINT))), getFilterAndProjectMinOutputPageSize(session), getFilterAndProjectMinOutputPageRowCount(session));
}
Also used : SymbolAllocator(io.trino.sql.planner.SymbolAllocator) PageFunctionCompiler(io.trino.sql.gen.PageFunctionCompiler) Symbol(io.trino.sql.planner.Symbol) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) RowExpression(io.trino.sql.relational.RowExpression) ImmutableMap(com.google.common.collect.ImmutableMap) PageProjection(io.trino.operator.project.PageProjection) InputPageProjection(io.trino.operator.project.InputPageProjection) NodeRef(io.trino.sql.tree.NodeRef) Type(io.trino.spi.type.Type) InputPageProjection(io.trino.operator.project.InputPageProjection) PageProcessor(io.trino.operator.project.PageProcessor) Expression(io.trino.sql.tree.Expression) RowExpression(io.trino.sql.relational.RowExpression)

Aggregations

SymbolAllocator (io.trino.sql.planner.SymbolAllocator)23 Symbol (io.trino.sql.planner.Symbol)16 Test (org.testng.annotations.Test)12 DynamicFilter (io.trino.spi.connector.DynamicFilter)11 Expression (io.trino.sql.tree.Expression)11 QueryId (io.trino.spi.QueryId)10 TestingColumnHandle (io.trino.spi.connector.TestingColumnHandle)10 DynamicFilterId (io.trino.sql.planner.plan.DynamicFilterId)10 StageId (io.trino.execution.StageId)9 TaskId (io.trino.execution.TaskId)8 DynamicFilters.createDynamicFilterExpression (io.trino.sql.DynamicFilters.createDynamicFilterExpression)7 ColumnHandle (io.trino.spi.connector.ColumnHandle)5 Type (io.trino.spi.type.Type)4 PlanNodeIdAllocator (io.trino.sql.planner.PlanNodeIdAllocator)4 ImmutableList (com.google.common.collect.ImmutableList)3 Metadata (io.trino.metadata.Metadata)3 Domain (io.trino.spi.predicate.Domain)3 TupleDomain (io.trino.spi.predicate.TupleDomain)3 PlanNode (io.trino.sql.planner.plan.PlanNode)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2