Search in sources :

Example 1 with RowExpressionOptimizer

use of com.facebook.presto.sql.relational.RowExpressionOptimizer in project presto by prestodb.

the class CommonSubExpressionBenchmark method rowExpression.

private RowExpression rowExpression(String value) {
    Expression expression = createExpression(value, METADATA, TypeProvider.copyOf(symbolTypes));
    Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes(TEST_SESSION, METADATA, SQL_PARSER, TypeProvider.copyOf(symbolTypes), expression, emptyList(), WarningCollector.NOOP);
    RowExpression rowExpression = SqlToRowExpressionTranslator.translate(expression, expressionTypes, sourceLayout, METADATA.getFunctionAndTypeManager(), TEST_SESSION);
    RowExpressionOptimizer optimizer = new RowExpressionOptimizer(METADATA);
    return optimizer.optimize(rowExpression, OPTIMIZED, TEST_SESSION.toConnectorSession());
}
Also used : NodeRef(com.facebook.presto.sql.tree.NodeRef) Type(com.facebook.presto.common.type.Type) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) FunctionAssertions.createExpression(com.facebook.presto.operator.scalar.FunctionAssertions.createExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) Expression(com.facebook.presto.sql.tree.Expression) RowExpression(com.facebook.presto.spi.relation.RowExpression) RowExpressionOptimizer(com.facebook.presto.sql.relational.RowExpressionOptimizer)

Example 2 with RowExpressionOptimizer

use of com.facebook.presto.sql.relational.RowExpressionOptimizer in project presto by prestodb.

the class PageProcessorBenchmark method rowExpression.

private RowExpression rowExpression(String value) {
    Expression expression = createExpression(value, METADATA, TypeProvider.copyOf(symbolTypes));
    Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes(TEST_SESSION, METADATA, SQL_PARSER, TypeProvider.copyOf(symbolTypes), expression, emptyList(), WarningCollector.NOOP);
    RowExpression rowExpression = SqlToRowExpressionTranslator.translate(expression, expressionTypes, sourceLayout, METADATA.getFunctionAndTypeManager(), TEST_SESSION);
    RowExpressionOptimizer optimizer = new RowExpressionOptimizer(METADATA);
    return optimizer.optimize(rowExpression, OPTIMIZED, TEST_SESSION.toConnectorSession());
}
Also used : NodeRef(com.facebook.presto.sql.tree.NodeRef) Type(com.facebook.presto.common.type.Type) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) FunctionAssertions.createExpression(com.facebook.presto.operator.scalar.FunctionAssertions.createExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) Expression(com.facebook.presto.sql.tree.Expression) RowExpression(com.facebook.presto.spi.relation.RowExpression) RowExpressionOptimizer(com.facebook.presto.sql.relational.RowExpressionOptimizer)

Example 3 with RowExpressionOptimizer

use of com.facebook.presto.sql.relational.RowExpressionOptimizer in project presto by prestodb.

the class TestingRowExpressionTranslator method translateAndOptimize.

public RowExpression translateAndOptimize(Expression expression, Map<NodeRef<Expression>, Type> types) {
    RowExpression rowExpression = SqlToRowExpressionTranslator.translate(expression, types, ImmutableMap.of(), metadata.getFunctionAndTypeManager(), TEST_SESSION);
    RowExpressionOptimizer optimizer = new RowExpressionOptimizer(metadata);
    return optimizer.optimize(rowExpression, OPTIMIZED, TEST_SESSION.toConnectorSession());
}
Also used : RowExpression(com.facebook.presto.spi.relation.RowExpression) RowExpressionOptimizer(com.facebook.presto.sql.relational.RowExpressionOptimizer)

Aggregations

RowExpression (com.facebook.presto.spi.relation.RowExpression)3 RowExpressionOptimizer (com.facebook.presto.sql.relational.RowExpressionOptimizer)3 Type (com.facebook.presto.common.type.Type)2 FunctionAssertions.createExpression (com.facebook.presto.operator.scalar.FunctionAssertions.createExpression)2 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)2 Expression (com.facebook.presto.sql.tree.Expression)2 NodeRef (com.facebook.presto.sql.tree.NodeRef)2