Search in sources :

Example 16 with CallExpression

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

the class TestInCodeGenerator method testInteger.

@Test
public void testInteger() {
    List<RowExpression> values = new ArrayList<>();
    values.add(new ConstantExpression(Integer.MIN_VALUE, INTEGER));
    values.add(new ConstantExpression(Integer.MAX_VALUE, INTEGER));
    values.add(new ConstantExpression(3, INTEGER));
    assertEquals(checkSwitchGenerationCase(INTEGER, values), DIRECT_SWITCH);
    values.add(new ConstantExpression(null, INTEGER));
    assertEquals(checkSwitchGenerationCase(INTEGER, values), DIRECT_SWITCH);
    values.add(new CallExpression(new Signature(CAST, SCALAR, INTEGER.getTypeSignature(), DOUBLE.getTypeSignature()), INTEGER, Collections.singletonList(new ConstantExpression(12345678901234.0, DOUBLE))));
    assertEquals(checkSwitchGenerationCase(INTEGER, values), DIRECT_SWITCH);
    for (int i = 6; i <= 32; ++i) {
        values.add(new ConstantExpression(i, INTEGER));
    }
    assertEquals(checkSwitchGenerationCase(INTEGER, values), DIRECT_SWITCH);
    values.add(new ConstantExpression(33, INTEGER));
    assertEquals(checkSwitchGenerationCase(INTEGER, values), SET_CONTAINS);
}
Also used : ConstantExpression(com.facebook.presto.sql.relational.ConstantExpression) Signature(com.facebook.presto.metadata.Signature) ArrayList(java.util.ArrayList) RowExpression(com.facebook.presto.sql.relational.RowExpression) CallExpression(com.facebook.presto.sql.relational.CallExpression) Test(org.testng.annotations.Test)

Aggregations

CallExpression (com.facebook.presto.sql.relational.CallExpression)16 Signature (com.facebook.presto.metadata.Signature)11 ConstantExpression (com.facebook.presto.sql.relational.ConstantExpression)11 RowExpression (com.facebook.presto.sql.relational.RowExpression)11 Test (org.testng.annotations.Test)9 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)7 InputReferenceExpression (com.facebook.presto.sql.relational.InputReferenceExpression)7 Parameter (com.facebook.presto.bytecode.Parameter)5 LambdaDefinitionExpression (com.facebook.presto.sql.relational.LambdaDefinitionExpression)5 BytecodeBlock (com.facebook.presto.bytecode.BytecodeBlock)4 MethodDefinition (com.facebook.presto.bytecode.MethodDefinition)4 Scope (com.facebook.presto.bytecode.Scope)4 PageProcessor (com.facebook.presto.operator.PageProcessor)4 ExpressionCompiler (com.facebook.presto.sql.gen.ExpressionCompiler)4 BlockEncodingManager (com.facebook.presto.block.BlockEncodingManager)3 FieldDefinition (com.facebook.presto.bytecode.FieldDefinition)3 Variable (com.facebook.presto.bytecode.Variable)3 FunctionRegistry (com.facebook.presto.metadata.FunctionRegistry)3 Page (com.facebook.presto.spi.Page)3 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)3