use of com.facebook.presto.sql.planner.RowExpressionInterpreter in project presto by prestodb.
the class TestExpressionInterpreter method optimize.
private static Object optimize(RowExpression expression, Level level) {
return new RowExpressionInterpreter(expression, METADATA, TEST_SESSION.toConnectorSession(), level).optimize(variable -> {
Symbol symbol = new Symbol(variable.getName());
Object value = symbolConstant(symbol);
if (value == null) {
return new VariableReferenceExpression(Optional.empty(), symbol.getName(), SYMBOL_TYPES.get(symbol.toSymbolReference()));
}
return value;
});
}
use of com.facebook.presto.sql.planner.RowExpressionInterpreter in project presto by prestodb.
the class FilterStatsCalculator method simplifyExpression.
private RowExpression simplifyExpression(ConnectorSession session, RowExpression predicate) {
RowExpressionInterpreter interpreter = new RowExpressionInterpreter(predicate, metadata, session, OPTIMIZED);
Object value = interpreter.optimize();
if (value == null) {
// Expression evaluates to SQL null, which in Filter is equivalent to false. This assumes the expression is a top-level expression (eg. not in NOT).
value = false;
}
return LiteralEncoder.toRowExpression(predicate.getSourceLocation(), value, BOOLEAN);
}
Aggregations