use of com.facebook.presto.sql.tree.NodeRef in project presto by prestodb.
the class TestSqlToRowExpressionTranslator method testPossibleExponentialOptimizationTime.
@Test(timeOut = 10_000)
public void testPossibleExponentialOptimizationTime() {
Expression expression = new LongLiteral("1");
ImmutableMap.Builder<NodeRef<Expression>, Type> types = ImmutableMap.builder();
types.put(NodeRef.of(expression), BIGINT);
for (int i = 0; i < 100; i++) {
expression = new CoalesceExpression(expression, new LongLiteral("2"));
types.put(NodeRef.of(expression), BIGINT);
}
translator.translateAndOptimize(expression, types.build());
}
use of com.facebook.presto.sql.tree.NodeRef 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());
}
use of com.facebook.presto.sql.tree.NodeRef 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());
}
use of com.facebook.presto.sql.tree.NodeRef in project presto by prestodb.
the class TestCommonSubExpressionRewritter method rowExpression.
private RowExpression rowExpression(String sql) {
Expression expression = rewriteIdentifiersToSymbolReferences(new SqlParser().createExpression(sql));
Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes(SESSION, METADATA, new SqlParser(), TYPES, expression, ImmutableList.of(), WarningCollector.NOOP);
return SqlToRowExpressionTranslator.translate(expression, expressionTypes, ImmutableMap.of(), METADATA.getFunctionAndTypeManager(), SESSION);
}
use of com.facebook.presto.sql.tree.NodeRef in project presto by prestodb.
the class TestingRowExpressionTranslator method simplifyExpression.
Expression simplifyExpression(Expression expression) {
// Testing simplified expressions is important, since simplification may create CASTs or function calls that cannot be simplified by the ExpressionOptimizer
Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes(expression, TypeProvider.empty());
ExpressionInterpreter interpreter = ExpressionInterpreter.expressionOptimizer(expression, metadata, TEST_SESSION, expressionTypes);
Object value = interpreter.optimize(NoOpVariableResolver.INSTANCE);
return literalEncoder.toExpression(value, expressionTypes.get(NodeRef.of(expression)));
}
Aggregations