sourceTypes);
return new PhysicalOperation(operatorFactory, outputMappings);
}
else {
OperatorFactory operatorFactory = compiler.compileFilterAndProjectOperator(context.getNextOperatorId(), rewrittenFilter, rewrittenProjections, sourceTypes);
return new PhysicalOperation(operatorFactory, outputMappings, source);
}
}
catch (RuntimeException e) {
// compilation failed, use interpreter
log.error(e, "Compile failed for filter=%s projections=%s sourceTypes=%s error=%s", filterExpression, projectionExpressions, sourceTypes, e);
}
FilterFunction filterFunction;
if (filterExpression != BooleanLiteral.TRUE_LITERAL) {
filterFunction = new InterpretedFilterFunction(filterExpression, sourceLayout, metadata, context.getSession());
}
else {
filterFunction = FilterFunctions.TRUE_FUNCTION;
}
List<ProjectionFunction> projectionFunctions = new ArrayList<>();
for (int i = 0; i < projectionExpressions.size(); i++) {
Symbol symbol = outputSymbols.get(i);
Expression expression = projectionExpressions.get(i);
ProjectionFunction function;
if (expression instanceof QualifiedNameReference) {
// fast path when we know it's a direct symbol reference
Symbol reference = Symbol.fromQualifiedName(((QualifiedNameReference) expression).getName());
function = ProjectionFunctions.singleColumn(context.getTypes().get(reference).getRawType(), sourceLayout.get(reference));
}
else {
function = new InterpretedProjectionFunction(
context.getTypes().get(symbol),
expression,
sourceLayout,
metadata,
context.getSession()
);
}
projectionFunctions.add(function);
}
if (columns != null) {
OperatorFactory operatorFactory = new ScanFilterAndProjectOperatorFactory(
context.getNextOperatorId(),
sourceNode.getId(),
dataStreamProvider,
columns,
filterFunction,
projectionFunctions);
return new PhysicalOperation(operatorFactory, outputMappings);
}
else {
OperatorFactory operatorFactory = new FilterAndProjectOperatorFactory(context.getNextOperatorId(), filterFunction, projectionFunctions);
return new PhysicalOperation(operatorFactory, outputMappings, source);
}
}