use of io.trino.sql.tree.NodeRef in project trino by trinodb.
the class PartialTranslator method extractPartialTranslations.
/**
* Produces {@link ConnectorExpression} translations for disjoint components in the {@param inputExpression} in a
* top-down manner. i.e. if an expression node is translatable, we do not consider its children.
*/
public static Map<NodeRef<Expression>, ConnectorExpression> extractPartialTranslations(Expression inputExpression, Session session, TypeAnalyzer typeAnalyzer, TypeProvider typeProvider, PlannerContext plannerContext) {
requireNonNull(inputExpression, "inputExpression is null");
requireNonNull(session, "session is null");
requireNonNull(typeAnalyzer, "typeAnalyzer is null");
requireNonNull(typeProvider, "typeProvider is null");
Map<NodeRef<Expression>, ConnectorExpression> partialTranslations = new HashMap<>();
new Visitor(session, typeAnalyzer.getTypes(session, typeProvider, inputExpression), partialTranslations, plannerContext).process(inputExpression);
return ImmutableMap.copyOf(partialTranslations);
}
use of io.trino.sql.tree.NodeRef 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));
}
Aggregations