session.getTimeZoneKey());
return new PhysicalOperation(operatorFactory, outputMappings);
}
else {
OperatorFactory operatorFactory = compiler.compileFilterAndProjectOperator(
context.getNextOperatorId(),
rewrittenFilter,
rewrittenProjections,
expressionTypes,
session.getTimeZoneKey());
return new PhysicalOperation(operatorFactory, outputMappings, source);
}
}
catch (RuntimeException e) {
if (!interpreterEnabled) {
throw 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, context.getTypes(), sourceLayout, metadata, context.getSession());
}
else {
filterFunction = FilterFunctions.TRUE_FUNCTION;
}
List<ProjectionFunction> projectionFunctions = new ArrayList<>();
for (Expression expression : projectionExpressions) {
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), sourceLayout.get(reference));
}
else {
function = new InterpretedProjectionFunction(
expression,
context.getTypes(),
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);
}
}